class Calculator::Token
Definition of a simple token with an attribute (@tag) and a value (@val)
- Author
-
Massimiliano Dal Mas (max.codeware@gmail.com)
- License
-
Distributed under MIT license
Public Class Methods
new(value)
click to toggle source
-
*argument*: value to tokenize (String)
# 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
Public Instance Methods
tag()
click to toggle source
-
*returns*: tag of the token
# File lib/linmeric/Calculator.rb, line 45 def tag return @tag end
value()
click to toggle source
-
*returns*: value of the token
# File lib/linmeric/Calculator.rb, line 40 def value return @val end