Class: Unitwise::Expression::Parser

Inherits:
Parslet::Parser
  • Object
show all
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

Instance Method Summary collapse

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

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/unitwise/expression/parser.rb', line 6

def key
  @key
end