Class: Proxy::DHCP::Infoblox::RangeRegularExpressionGenerator::MergedNode
- Inherits:
-
Object
- Object
- Proxy::DHCP::Infoblox::RangeRegularExpressionGenerator::MergedNode
- Defined in:
- lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #as_regex ⇒ Object
-
#initialize(a_node) ⇒ MergedNode
constructor
A new instance of MergedNode.
- #merge(other) ⇒ Object
- #value_as_regex ⇒ Object
Constructor Details
#initialize(a_node) ⇒ MergedNode
Returns a new instance of MergedNode.
51 52 53 54 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 51 def initialize(a_node) @value = [a_node.value].flatten @children = a_node.children end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
50 51 52 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 50 def children @children end |
#value ⇒ Object
Returns the value of attribute value.
50 51 52 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 50 def value @value end |
Instance Method Details
#==(other) ⇒ Object
69 70 71 72 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 69 def ==(other) return false if self.class != other.class value == other.value end |
#as_regex ⇒ Object
61 62 63 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 61 def as_regex children.empty? ? [value_as_regex] : children.map {|c| c.as_regex.map {|r| value_as_regex + r}}.flatten end |
#merge(other) ⇒ Object
56 57 58 59 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 56 def merge(other) value.push(other.value).flatten! self end |
#value_as_regex ⇒ Object
65 66 67 |
# File 'lib/smart_proxy_dhcp_infoblox/network_address_range_regex_generator.rb', line 65 def value_as_regex value.size < 2 ? value.first.to_s : "[#{value.join('')}]" end |