Class: TOML::Parser
- Inherits:
-
Object
- Object
- TOML::Parser
- Defined in:
- lib/toml/parser.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize(content, options = {}) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(content, options = {}) ⇒ Parser
Returns a new instance of Parser.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/toml/parser.rb', line 5 def initialize(content, = {}) @hash = {} @current = @hash parsed = Document.parse(content) parsed.matches.map(&:value).compact.each do |match| if match.is_a? Keygroup @current = match.navigate_keys(@hash, [:symbolize_keys]) elsif match.is_a? Keyvalue match.assign(@current, [:symbolize_keys]) end end end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
3 4 5 |
# File 'lib/toml/parser.rb', line 3 def hash @hash end |