Class: IP4Addr

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/logstash/codecs/netflow/util.rb

Instance Method Summary collapse

Instance Method Details

#getObject



17
18
19
# File 'lib/logstash/codecs/netflow/util.rb', line 17

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

#set(val) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/logstash/codecs/netflow/util.rb', line 9

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