Class: Unitwise::Expression::Parser
- Inherits:
-
Parslet::Parser
- Object
- Parslet::Parser
- Unitwise::Expression::Parser
- Defined in:
- lib/unitwise/expression/parser.rb
Overview
Parses a string expression into a hash tree representing the expression’s terms, prefixes, and atoms.
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key = :primary_code) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(key = :primary_code) ⇒ Parser
Returns a new instance of Parser.
7 8 9 10 11 12 |
# File 'lib/unitwise/expression/parser.rb', line 7 def initialize(key = :primary_code) @key = key @atom_matcher = Matcher.atom(key) @metric_atom_matcher = Matcher.metric_atom(key) @prefix_matcher = Matcher.prefix(key) end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/unitwise/expression/parser.rb', line 6 def key @key end |