Class: Pio::Type::IpAddress

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/pio/type/ip_address.rb

Overview

IP address

Instance Method Summary collapse

Instance Method Details

#&(other) ⇒ Object



24
25
26
# File 'lib/pio/type/ip_address.rb', line 24

def &(other)
  get.to_i & other
end

#==(other) ⇒ Object



28
29
30
# File 'lib/pio/type/ip_address.rb', line 28

def ==(other)
  get == other
end

#>>(other) ⇒ Object



20
21
22
# File 'lib/pio/type/ip_address.rb', line 20

def >>(other)
  get.to_i >> other
end

#getObject



16
17
18
# File 'lib/pio/type/ip_address.rb', line 16

def get
  IPv4Address.new(octets.map { |each| format('%d', each) }.join('.'))
end

#inspectObject



36
37
38
# File 'lib/pio/type/ip_address.rb', line 36

def inspect
  %("#{get}")
end

#set(value) ⇒ Object



12
13
14
# File 'lib/pio/type/ip_address.rb', line 12

def set(value)
  self.octets = IPv4Address.new(value).to_a
end

#to_bytesObject



32
33
34
# File 'lib/pio/type/ip_address.rb', line 32

def to_bytes
  octets.map(&:to_hex).join(', ')
end