Method: Calculator::Token#initialize

Defined in:
lib/linmeric/Calculator.rb

#initialize(value) ⇒ Token

  • argument: value to tokenize (String)



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/linmeric/Calculator.rb', line 25

def initialize(value)
  @val = value
  if OP.include? value then
    @tag = :OPERATOR
  elsif value.number? then
    @tag = :NUMBER
    @val = value.to_n
  elsif value == "(" then
    @tag = :L_PAR
  elsif value == ")" then
    @tag = :R_PAR
  end
end