Class: Ipv4Network

Inherits:
BasicNetworkType show all
Defined in:
lib/ifconfig/common/network_types.rb

Overview

Ipv4 Network type Optional Broadcast and Point to Point Arguments

Instance Attribute Summary collapse

Attributes inherited from BasicNetworkType

#nettype

Instance Method Summary collapse

Constructor Details

#initialize(addr, mask, bcast = nil, ptp = nil) ⇒ Ipv4Network

Returns a new instance of Ipv4Network.



18
19
20
21
22
23
24
25
# File 'lib/ifconfig/common/network_types.rb', line 18

def initialize(addr,mask,bcast=nil,ptp=nil)
  super()
  @nettype = 'inet'
  @addr = IPAddr.new(addr)
  @bcast = bcast
  @mask = mask
  @ptp = ptp
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



26
27
28
# File 'lib/ifconfig/common/network_types.rb', line 26

def addr
  @addr
end

#bcastObject (readonly)

Returns the value of attribute bcast.



26
27
28
# File 'lib/ifconfig/common/network_types.rb', line 26

def bcast
  @bcast
end

#maskObject (readonly)

Returns the value of attribute mask.



26
27
28
# File 'lib/ifconfig/common/network_types.rb', line 26

def mask
  @mask
end

#ptpObject (readonly)

Returns the value of attribute ptp.



26
27
28
# File 'lib/ifconfig/common/network_types.rb', line 26

def ptp
  @ptp
end

Instance Method Details

#to_sObject



28
29
30
31
32
33
# File 'lib/ifconfig/common/network_types.rb', line 28

def to_s
  a = [" #{@nettype} Address: #{@addr}","Mask: #{@mask}"]
  a.push "Broadcast: #{@bcast}" unless @bcast.nil?
  a.push "P-t-P: #{@ptp}" unless @ptp.nil?
  return a.join(', ')
end