Class: Babushka::IP
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Returns the value of attribute bytes.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(input) ⇒ IP
constructor
A new instance of IP.
- #next ⇒ Object
- #prev ⇒ Object
- #to_s ⇒ Object
-
#valid? ⇒ Boolean
Returns whether this IP should be considered a valid one for a client to be using.
Constructor Details
#initialize(input) ⇒ IP
Returns a new instance of IP.
5 6 7 |
# File 'lib/babushka/ip.rb', line 5 def initialize input @bytes = sanitize input end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Returns the value of attribute bytes.
3 4 5 |
# File 'lib/babushka/ip.rb', line 3 def bytes @bytes end |
Instance Method Details
#==(other) ⇒ Object
13 14 15 |
# File 'lib/babushka/ip.rb', line 13 def == other bytes == other.bytes end |
#next ⇒ Object
22 23 24 |
# File 'lib/babushka/ip.rb', line 22 def next offset_by(1) end |
#prev ⇒ Object
26 27 28 |
# File 'lib/babushka/ip.rb', line 26 def prev offset_by(-1) end |
#to_s ⇒ Object
9 10 11 |
# File 'lib/babushka/ip.rb', line 9 def to_s bytes.join '.' end |
#valid? ⇒ Boolean
Returns whether this IP should be considered a valid one for a client to be using.
18 19 20 |
# File 'lib/babushka/ip.rb', line 18 def valid? [:public, :private, :loopback].include? describe end |