Class: Hocon::Impl::PathBuilder
- Inherits:
-
Object
- Object
- Hocon::Impl::PathBuilder
- Defined in:
- lib/hocon/impl/path_builder.rb
Instance Method Summary collapse
- #append_key(key) ⇒ Object
- #check_can_append ⇒ Object
-
#initialize ⇒ PathBuilder
constructor
A new instance of PathBuilder.
- #result ⇒ Object
Constructor Details
#initialize ⇒ PathBuilder
Returns a new instance of PathBuilder.
6 7 8 9 |
# File 'lib/hocon/impl/path_builder.rb', line 6 def initialize @keys = [] @result = nil end |
Instance Method Details
#append_key(key) ⇒ Object
17 18 19 20 |
# File 'lib/hocon/impl/path_builder.rb', line 17 def append_key(key) check_can_append @keys.push(key) end |
#check_can_append ⇒ Object
11 12 13 14 15 |
# File 'lib/hocon/impl/path_builder.rb', line 11 def check_can_append if @result raise ConfigBugError, "Adding to PathBuilder after getting result" end end |
#result ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hocon/impl/path_builder.rb', line 22 def result # note: if keys is empty, we want to return null, which is a valid # empty path if @result.nil? remainder = nil while !@keys.empty? key = @keys.pop remainder = Hocon::Impl::Path.new(key, remainder) end @result = remainder end @result end |