Class: Hocon::Impl::ConfigNodeField
- Inherits:
-
Object
- Object
- Hocon::Impl::ConfigNodeField
- Includes:
- AbstractConfigNode
- Defined in:
- lib/hocon/impl/config_node_field.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #comments ⇒ Object
-
#initialize(children) ⇒ ConfigNodeField
constructor
A new instance of ConfigNodeField.
- #path ⇒ Object
- #replace_value(new_value) ⇒ Object
- #separator ⇒ Object
- #tokens ⇒ Object
- #value ⇒ Object
Methods included from AbstractConfigNode
Methods included from Parser::ConfigNode
Constructor Details
#initialize(children) ⇒ ConfigNodeField
Returns a new instance of ConfigNodeField.
17 18 19 |
# File 'lib/hocon/impl/config_node_field.rb', line 17 def initialize(children) @children = children end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
21 22 23 |
# File 'lib/hocon/impl/config_node_field.rb', line 21 def children @children end |
Instance Method Details
#comments ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/hocon/impl/config_node_field.rb', line 72 def comments comments = [] @children.each do |child| if child.is_a?(Hocon::Impl::ConfigNodeComment) comments << child.comment_text end end comments end |
#path ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/hocon/impl/config_node_field.rb', line 51 def path @children.each do |child| if child.is_a?(Hocon::Impl::ConfigNodePath) return child end end raise Hocon::ConfigError::ConfigBugOrBrokenError, "Field node doesn't have a path" end |
#replace_value(new_value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hocon/impl/config_node_field.rb', line 31 def replace_value(new_value) children_copy = @children.clone children_copy.each_with_index do |child, i| if child.is_a?(Hocon::Impl::AbstractConfigNodeValue) children_copy[i] = new_value return self.class.new(children_copy) end end raise Hocon::ConfigError::ConfigBugOrBrokenError, "Field node doesn't have a value" end |
#separator ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hocon/impl/config_node_field.rb', line 60 def separator @children.each do |child| if child.is_a?(Hocon::Impl::ConfigNodeSingleToken) t = child.token if t == Tokens::PLUS_EQUALS or t == Tokens::COLON or t == Tokens::EQUALS return t end end end nil end |
#tokens ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/hocon/impl/config_node_field.rb', line 23 def tokens tokens = [] @children.each do |child| tokens += child.tokens end tokens end |
#value ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/hocon/impl/config_node_field.rb', line 42 def value @children.each do |child| if child.is_a?(Hocon::Impl::AbstractConfigNodeValue) return child end end raise Hocon::ConfigError::ConfigBugOrBrokenError, "Field node doesn't have a value" end |