Class: Hocon::Impl::ConfigNodeSimpleValue
- Inherits:
-
Object
- Object
- Hocon::Impl::ConfigNodeSimpleValue
- Includes:
- AbstractConfigNodeValue
- Defined in:
- lib/hocon/impl/config_node_simple_value.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(value) ⇒ ConfigNodeSimpleValue
constructor
A new instance of ConfigNodeSimpleValue.
- #tokens ⇒ Object
- #value ⇒ Object
Methods included from AbstractConfigNode
Methods included from Parser::ConfigNode
Constructor Details
#initialize(value) ⇒ ConfigNodeSimpleValue
Returns a new instance of ConfigNodeSimpleValue.
18 19 20 |
# File 'lib/hocon/impl/config_node_simple_value.rb', line 18 def initialize(value) @token = value end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
22 23 24 |
# File 'lib/hocon/impl/config_node_simple_value.rb', line 22 def token @token end |
Instance Method Details
#tokens ⇒ Object
24 25 26 |
# File 'lib/hocon/impl/config_node_simple_value.rb', line 24 def tokens [@token] end |
#value ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hocon/impl/config_node_simple_value.rb', line 28 def value if Tokens.value?(@token) return Tokens.value(@token) elsif Tokens.unquoted_text?(@token) return Hocon::Impl::ConfigString::Unquoted.new(@token.origin, Tokens.unquoted_text(@token)) elsif Tokens.substitution?(@token) expression = Tokens.get_substitution_path_expression(@token) path = Hocon::Impl::PathParser.parse_path_expression(Hocon::Impl::ArrayIterator.new(expression), @token.origin) optional = Tokens.get_substitution_optional(@token) return Hocon::Impl::ConfigReference.new(@token.origin, Hocon::Impl::SubstitutionExpression.new(path, optional)) end raise Hocon::ConfigError::ConfigBugOrBrokenError, 'ConfigNodeSimpleValue did not contain a valid value token' end |