Class: IpMethods::SimpleIP

Inherits:
Object
  • Object
show all
Includes:
IpMethods
Defined in:
lib/ip_methods.rb

Constant Summary

Constants included from IpMethods

IPV4_BIT_OCTET, IPV4_BIT_WIDTH, IPV4_PATTERN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IpMethods

#belongs_to?, #broadcast, #broadcast_bin, #default_gateway, from_bin, #generate_ips, ip?, ip_and_mask?, mask?, #mask_bin, #net_mask, #network, #network_bin, #to_bin, to_bin, #umask_bin

Constructor Details

#initialize(address, mask = 32) ⇒ SimpleIP

Returns a new instance of SimpleIP.



93
94
95
96
97
# File 'lib/ip_methods.rb', line 93

def initialize(address, mask = 32)
  (@address, @mask) = address.split('/')
  @mask ||= mask
  @mask = @mask.to_i
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



91
92
93
# File 'lib/ip_methods.rb', line 91

def address
  @address
end

#maskObject

Returns the value of attribute mask.



91
92
93
# File 'lib/ip_methods.rb', line 91

def mask
  @mask
end