Class: Fluent::Plugin::NetflowParser::IP4Addr

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/fluent/plugin/netflow_records.rb

Instance Method Summary collapse

Instance Method Details

#getObject



18
19
20
# File 'lib/fluent/plugin/netflow_records.rb', line 18

def get
  IPAddr.new_ntoh([self.storage].pack('N')).to_s
end

#set(val) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/fluent/plugin/netflow_records.rb', line 10

def set(val)
  ip = IPAddr.new(val)
  if ! ip.ipv4?
    raise ArgumentError, "invalid IPv4 address '#{val}'"
  end
  self.storage = ip.to_i
end