Class: Iface::ValueSet::IpV6Secondaries
- Inherits:
-
Pair
- Object
- Pair
- Iface::ValueSet::IpV6Secondaries
show all
- Defined in:
- lib/iface/value_set/pair.rb
Overview
Represents a pair for IPV6ADDR_SECONDARIES
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) ⇒ IpV6Secondaries
Returns a new instance of IpV6Secondaries.
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/iface/value_set/pair.rb', line 84
def initialize(_name, value, value_set)
super('IPV6ADDR_SECONDARIES', value, value_set)
case value
when String
self.value = value.split(/ +/)
when Array
self.value = value
else
raise ArgumentError, "Expected String or Array; got #{value.class.name}: #{value.inspect}"
end
end
|
Instance Method Details
#filter_primary!(primary_num) ⇒ Object
111
112
113
114
|
# File 'lib/iface/value_set/pair.rb', line 111
def filter_primary!(primary_num)
@value = @value.reject { |ip_num, _mask| ip_num == primary_num }
self
end
|
#value ⇒ Object
107
108
109
|
# File 'lib/iface/value_set/pair.rb', line 107
def value
@value.map { |ip_num, mask| "#{IpV6Address.from_numeric(ip_num)}/#{mask}" }.join(' ')
end
|
#value=(new_value) ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/iface/value_set/pair.rb', line 96
def value=(new_value)
ips = new_value.map do |ip_with_mask|
ip, mask = ip_with_mask.split(%r{/})
[IpV6Address.new(ip).to_i, mask || 128]
end.uniq.sort
@value = ips
ipv6_primary = @value_set.fetch_raw('ipv6addr')
filter_primary!(ipv6_primary) if ipv6_primary
self
end
|