Class: BoostInfo::Parser
- Inherits:
-
Object
- Object
- BoostInfo::Parser
- Defined in:
- lib/boost_info/parser.rb
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- OPEN_TOKEN =
'{'- CLOSE_TOKEN =
'}'
Instance Attribute Summary collapse
-
#root_node ⇒ Object
Returns the value of attribute root_node.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, opts = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse_hash ⇒ Object
- #parse_info ⇒ Object
Constructor Details
Instance Attribute Details
#root_node ⇒ Object
Returns the value of attribute root_node.
7 8 9 |
# File 'lib/boost_info/parser.rb', line 7 def root_node @root_node end |
Class Method Details
.from_hash(source, opts = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/boost_info/parser.rb', line 26 def self.from_hash(source, opts={}) unless source.is_a?(Hash) fail TypeError, "no implicit conversion of #{source.class} into Hash" end new(source, opts).parse_hash end |
.from_info(source, opts = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/boost_info/parser.rb', line 19 def self.from_info(source, opts={}) unless source.is_a?(String) fail TypeError, "no implicit conversion of #{source.class} into String" end new(source, opts).parse_info end |
Instance Method Details
#parse_hash ⇒ Object
40 41 42 43 44 |
# File 'lib/boost_info/parser.rb', line 40 def parse_hash traverse_hash(@source, @root_node) @root_node end |
#parse_info ⇒ Object
33 34 35 36 37 38 |
# File 'lib/boost_info/parser.rb', line 33 def parse_info lines = process_source(@source) traverse_info(@root_node, lines, -1) @root_node end |