Class Net::DNS::Resolver::DnsTimeout
In: lib/net/dns/resolver/timeouts.rb
Parent: Object

Methods

new   pretty_to_s   timeout   to_s  

Attributes

seconds  [R] 

Public Class methods

[Source]

# File lib/net/dns/resolver/timeouts.rb, line 12
        def initialize(seconds)
          if seconds.is_a? Numeric and seconds >= 0
            @seconds = seconds
          else
            raise ::ArgumentError, "Invalid value for tcp timeout"
          end
        end

Public Instance methods

[Source]

# File lib/net/dns/resolver/timeouts.rb, line 30
        def pretty_to_s
          transform(@seconds)
        end

Executes the method‘s block. If the block execution terminates before sec seconds has passed, it returns true. If not, it terminates the execution and raises Timeout::Error. If @seconds is 0 or nil, no timeout is set.

[Source]

# File lib/net/dns/resolver/timeouts.rb, line 38
        def timeout(&block)
          raise LocalJumpError, "no block given" unless block_given?
          Timeout.timeout(@seconds, &block)
        end

Returns a string representation of the timeout corresponding to the number of @seconds.

[Source]

# File lib/net/dns/resolver/timeouts.rb, line 22
        def to_s
          if @seconds == 0
            @output.to_s
          else
            @seconds.to_s
          end
        end

[Validate]