Module: BetterIpaddr::HostMethods

Included in:
IPAddr::V4::Host, IPAddr::V6::Host
Defined in:
lib/better_ipaddr/host_methods.rb

Instance Method Summary collapse

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

#eachEnumerator

Return an enumerator with the behavior described above.



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

#firstIPAddr

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

#initializeObject



3
4
5
6
# File 'lib/better_ipaddr/host_methods.rb', line 3

def initialize(*)
  super
  @mask_addr = netmask.to_i
end

#lastIPAddr

Returns the object.



47
48
49
# File 'lib/better_ipaddr/host_methods.rb', line 47

def last
  self
end

#netmaskObject

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_lengthObject

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

#sizeObject

Returns 1.



62
63
64
# File 'lib/better_ipaddr/host_methods.rb', line 62

def size
  1
end