Class: SflowIP6Addr

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

Overview

noinspection RubyResolve

Instance Method Summary collapse

Instance Method Details

#getObject



51
52
53
54
55
# File 'lib/logstash/codecs/sflow/util.rb', line 51

def get
  IPAddr.new_ntoh((0..7).map { |i|
    (self.storage >> (112 - 16 * i)) & 0xffff
  }.pack('n8')).to_s
end

#set(val) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/logstash/codecs/sflow/util.rb', line 43

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