Class: TOML::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/toml/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @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, options[:symbolize_keys])
    elsif match.is_a? Keyvalue
      match.assign(@current, options[:symbolize_keys])
    end
  end
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



3
4
5
# File 'lib/toml/parser.rb', line 3

def hash
  @hash
end