Class: TOMLP::Parser

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

Overview

Methods which help in parsing the content

Constant Summary collapse

@@parser =
TomlParser.new

Instance Method Summary collapse

Constructor Details

#initialize(content) ⇒ Parser

Public: Initialize a Parser.

name - A String stroring the contents of the file



19
20
21
# File 'lib/tomlp/parser.rb', line 19

def initialize(content)
  @content = content.dup
end

Instance Method Details

#parseObject

Public: Method to parse the document.

Returns the parsed Data Structure



26
27
28
29
30
31
# File 'lib/tomlp/parser.rb', line 26

def parse
  @content += "\n" unless @content.end_with?("\n")
  tree = @@parser.parse(@content)
  Parser.clean_tree(tree)
  tree.evaluate
end