Module: BetterIpaddr::HostMethods
- Included in:
- IPAddr::V4::Host, IPAddr::V6::Host
- Defined in:
- lib/better_ipaddr/host_methods.rb,
lib/better_ipaddr/kernel_method.rb
Overview
Methods included in IPAddr::IPV4::Host and IPAddr::IPV6::Host
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
-
#inspect(cidr: false, full: false) ⇒ Object
Same as BetterIpaddr::InstanceMethods#inspect but doesn’t by default include the CIDR prefix length.
-
#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.
11 12 13 |
# File 'lib/better_ipaddr/host_methods.rb', line 11 def cover?(other) self == other end |
#each ⇒ Enumerator
24 25 26 27 28 29 30 |
# File 'lib/better_ipaddr/host_methods.rb', line 24 def each if block_given? yield self else enum_for(:each) end end |
#first ⇒ IPAddr
Returns the object.
35 36 37 |
# File 'lib/better_ipaddr/host_methods.rb', line 35 def first self end |
#host? ⇒ Boolean
Returns true.
41 42 43 |
# File 'lib/better_ipaddr/host_methods.rb', line 41 def host? true end |
#initialize ⇒ Object
4 5 6 7 |
# File 'lib/better_ipaddr/host_methods.rb', line 4 def initialize(*) super @mask_addr = netmask.to_i end |
#inspect(cidr: false, full: false) ⇒ Object
Same as BetterIpaddr::InstanceMethods#inspect but doesn’t by default include the CIDR prefix length.
34 35 36 |
# File 'lib/better_ipaddr/kernel_method.rb', line 34 def inspect(cidr: false, full: false) "#{self.class}['#{better_to_s(cidr: cidr, full: full)}']" end |
#last ⇒ IPAddr
Returns the object.
48 49 50 |
# File 'lib/better_ipaddr/host_methods.rb', line 48 def last self end |
#netmask ⇒ Object
Returns the netmask for a host address.
53 54 55 |
# File 'lib/better_ipaddr/host_methods.rb', line 53 def netmask self.class::HOST_NETMASK end |
#prefix_length ⇒ Object
Returns the number of bits in the address.
58 59 60 |
# File 'lib/better_ipaddr/host_methods.rb', line 58 def prefix_length self.class::BIT_LENGTH end |
#size ⇒ Object
Returns 1.
63 64 65 |
# File 'lib/better_ipaddr/host_methods.rb', line 63 def size 1 end |