class Keisan::Tokens::ArithmeticOperator

Constants

DIVIDE
EXPONENT
MODULO
PLUS_OR_MINUS
REGEX
TIMES

Public Class Methods

regex() click to toggle source
# File lib/keisan/tokens/arithmetic_operator.rb, line 11
def self.regex
  REGEX
end

Public Instance Methods

operator_type() click to toggle source
# File lib/keisan/tokens/arithmetic_operator.rb, line 15
def operator_type
  case string
  when EXPONENT
    # Must match first to override matching against single "*"
    :**
  when TIMES
    :*
  when DIVIDE
    :/
  when MODULO
    :%
  when PLUS_OR_MINUS
    string.count("-").even? ? :+ : :-
  end
end