Class: SflowIP4Addr

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

Overview

noinspection RubyResolve,RubyResolve,RubyResolve

Instance Method Summary collapse

Instance Method Details

#getObject



33
34
35
# File 'lib/logstash/codecs/sflow/util.rb', line 33

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

#set(val) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/logstash/codecs/sflow/util.rb', line 25

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