Class: DNS::IP
- Inherits:
-
Object
- Object
- DNS::IP
- Defined in:
- lib/faildns/ip.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(what) ⇒ IP
constructor
A new instance of IP.
- #pack ⇒ Object
- #to_s ⇒ Object (also: #to_str)
Constructor Details
#initialize(what) ⇒ IP
Returns a new instance of IP.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/faildns/ip.rb', line 31 def initialize (what) if what.is_a?(String) @ip = IPAddr.new(what.to_s) elsif what.is_a?(IP) @ip = what.ip elsif what.is_a?(IPAddr) @ip = what else DNS.debug what.inspect raise ArgumentError.new 'wat is dis i dont even' end @version = (@ip.ipv4?) ? 4 : 6 end |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
29 30 31 |
# File 'lib/faildns/ip.rb', line 29 def ip @ip end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
29 30 31 |
# File 'lib/faildns/ip.rb', line 29 def version @version end |
Class Method Details
Instance Method Details
#pack ⇒ Object
46 47 48 |
# File 'lib/faildns/ip.rb', line 46 def pack @ip.hton end |
#to_s ⇒ Object Also known as: to_str
50 51 52 |
# File 'lib/faildns/ip.rb', line 50 def to_s @ip.to_s end |