Module: Hocon::Impl::ConfigNodeComplexValue
- Includes:
- AbstractConfigNodeValue
- Included in:
- ConfigNodeArray, ConfigNodeConcatenation, ConfigNodeObject, ConfigNodeRoot
- Defined in:
- lib/hocon/impl/config_node_complex_value.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #indent_text(indentation) ⇒ Object
- #initialize(children) ⇒ Object
-
#new_node(nodes) ⇒ Object
This method will just call into the object’s constructor, but it’s needed for use in the indentText() method so we can avoid a gross if/else statement checking the type of this.
- #tokens ⇒ Object
Methods included from AbstractConfigNode
Methods included from Parser::ConfigNode
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
17 18 19 |
# File 'lib/hocon/impl/config_node_complex_value.rb', line 17 def children @children end |
Instance Method Details
#indent_text(indentation) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hocon/impl/config_node_complex_value.rb', line 27 def indent_text(indentation) children_copy = @children.clone i = 0 while i < children_copy.size child = children_copy[i] if child.is_a?(Hocon::Impl::ConfigNodeSingleToken) && Hocon::Impl::Tokens.newline?(child.token) children_copy.insert(i + 1, indentation) i += 1 elsif child.is_a?(Hocon::Impl::ConfigNodeField) value = child.value if value.is_a?(Hocon::Impl::ConfigNodeComplexValue) children_copy[i] = child.replace_value(value.indent_text(indentation)) end elsif child.is_a?(Hocon::Impl::ConfigNodeComplexValue) children_copy[i] = child.indent_text(indentation) end i += 1 end new_node(children_copy) end |
#initialize(children) ⇒ Object
13 14 15 |
# File 'lib/hocon/impl/config_node_complex_value.rb', line 13 def initialize(children) @children = children end |
#new_node(nodes) ⇒ Object
This method will just call into the object’s constructor, but it’s needed for use in the indentText() method so we can avoid a gross if/else statement checking the type of this
51 52 53 |
# File 'lib/hocon/impl/config_node_complex_value.rb', line 51 def new_node(nodes) raise Hocon::ConfigError::ConfigBugOrBrokenError, "subclasses of ConfigNodeComplexValue should override `new_node` (#{self.class})" end |
#tokens ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/hocon/impl/config_node_complex_value.rb', line 19 def tokens tokens = [] @children.each do |child| tokens += child.tokens end tokens end |