Module: BetterIpaddr::HostMethods
- Included in:
- IPAddr::V4::Host, IPAddr::V6::Host
- Defined in:
- lib/better_ipaddr/host_methods.rb
Instance Method Summary collapse
-
#cover?(other) ⇒ Boolean
Returns true if the argument is the same as the receiver, false otherwise.
-
#each ⇒ Enumerator
Return an enumerator with the behavior described above.
-
#first ⇒ IPAddr
Returns the object.
-
#host? ⇒ Boolean
Returns true.
- #initialize ⇒ Object
-
#last ⇒ IPAddr
Returns the object.
-
#netmask ⇒ Object
Returns the netmask for a host address.
-
#prefix_length ⇒ Object
Returns the number of bits in the address.
-
#size ⇒ Object
Returns 1.
Instance Method Details
#cover?(other) ⇒ Boolean
Returns true if the argument is the same as the receiver, false otherwise.
10 11 12 |
# File 'lib/better_ipaddr/host_methods.rb', line 10 def cover?(other) self == other end |
#each ⇒ Enumerator
23 24 25 26 27 28 29 |
# File 'lib/better_ipaddr/host_methods.rb', line 23 def each if block_given? yield self else enum_for(:each) end end |
#first ⇒ IPAddr
Returns the object.
34 35 36 |
# File 'lib/better_ipaddr/host_methods.rb', line 34 def first self end |
#host? ⇒ Boolean
Returns true.
40 41 42 |
# File 'lib/better_ipaddr/host_methods.rb', line 40 def host? true end |
#initialize ⇒ Object
3 4 5 6 |
# File 'lib/better_ipaddr/host_methods.rb', line 3 def initialize(*) super @mask_addr = netmask.to_i end |
#last ⇒ IPAddr
Returns the object.
47 48 49 |
# File 'lib/better_ipaddr/host_methods.rb', line 47 def last self end |
#netmask ⇒ Object
Returns the netmask for a host address.
52 53 54 |
# File 'lib/better_ipaddr/host_methods.rb', line 52 def netmask self.class::HOST_NETMASK end |
#prefix_length ⇒ Object
Returns the number of bits in the address.
57 58 59 |
# File 'lib/better_ipaddr/host_methods.rb', line 57 def prefix_length self.class::BIT_LENGTH end |
#size ⇒ Object
Returns 1.
62 63 64 |
# File 'lib/better_ipaddr/host_methods.rb', line 62 def size 1 end |