Class: Iface::ValueSet::IpV6Primary

Inherits:
Pair
  • Object
show all
Defined in:
lib/iface/value_set/pair.rb

Overview

Represents a pair for IPV6ADDR, which is output in the form IPV6ADDR=“ipv6-address/prefix-length”

Instance Attribute Summary

Attributes inherited from Pair

#name

Instance Method Summary collapse

Methods inherited from Pair

create, #raw_value, #to_s

Constructor Details

#initialize(_name, value, value_set) ⇒ IpV6Primary

Returns a new instance of IpV6Primary.



63
64
65
66
# File 'lib/iface/value_set/pair.rb', line 63

def initialize(_name, value, value_set)
  super('IPV6ADDR', value, value_set)
  self.value = value
end

Instance Method Details

#valueObject



68
69
70
# File 'lib/iface/value_set/pair.rb', line 68

def value
  "#{IpV6Address.from_numeric(@value)}/#{@mask}"
end

#value=(new_value) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/iface/value_set/pair.rb', line 72

def value=(new_value)
  ip, mask = new_value.split(%r{/})
  ipaddr = IpV6Address.new(ip)
  @value = ipaddr.to_i
  @mask = mask || 64
  @value_set['ipv6_secondaries']&.filter_primary!(@value)
  self
end