Class: OpenConfig::Node
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- OpenConfig::Node
- Defined in:
- lib/open_config/node.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#fetch(name, *args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/open_config/node.rb', line 7 def fetch(name, *args, &block) begin name = name.to_sym rescue NoMethodError raise! TypeError, "#{name} is not a symbol nor a string" end table.fetch(name, *args, &block) end |
#pretty_print(q) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/open_config/node.rb', line 23 def pretty_print(q) q.object_group self do q.nest(1) do q.breakable q.seplist(table, nil, :each) do |key, value| q.group do q.text key.to_s q.text ': ' q.pp value end end end end end |
#to_h ⇒ Object
17 18 19 20 21 |
# File 'lib/open_config/node.rb', line 17 def to_h super.transform_values do |value| value.instance_of?(self.class) ? value.to_h : value end end |