Class: Pio::Type::IpAddress
- Inherits:
-
BinData::Primitive
- Object
- BinData::Primitive
- Pio::Type::IpAddress
- Defined in:
- lib/pio/type/ip_address.rb
Overview
IP address
Instance Method Summary collapse
- #&(other) ⇒ Object
- #==(other) ⇒ Object
- #>>(other) ⇒ Object
- #get ⇒ Object
- #inspect ⇒ Object
- #set(value) ⇒ Object
- #to_bytes ⇒ Object
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 |
#get ⇒ Object
16 17 18 |
# File 'lib/pio/type/ip_address.rb', line 16 def get IPv4Address.new(octets.map { |each| format('%d', each) }.join('.')) end |
#inspect ⇒ Object
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_bytes ⇒ Object
32 33 34 |
# File 'lib/pio/type/ip_address.rb', line 32 def to_bytes octets.map(&:to_hex).join(', ') end |