Class: Keisan::Tokens::Assignment

Inherits:
Operator show all
Defined in:
lib/keisan/tokens/assignment.rb

Constant Summary collapse

REGEX =
/(
  (?: # possible compound operators in front of equals
   \|\| |
   \&\& |
   \*\* |
   \+ |
   \- |
   \* |
   \/ |
   \% |
   \& |
   \| |
   \^ |
   \<\< |
   \>\>
  )?
  \=
  (?!\=) # negative lookahead to prevent matching ==
)/x

Instance Attribute Summary

Attributes inherited from Keisan::Token

#string

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Operator

#type

Methods inherited from Keisan::Token

#initialize, #regex, #type, type

Constructor Details

This class inherits a constructor from Keisan::Token

Class Method Details

.regexObject



24
25
26
# File 'lib/keisan/tokens/assignment.rb', line 24

def self.regex
  REGEX
end

Instance Method Details

#compound_operatorObject



32
33
34
# File 'lib/keisan/tokens/assignment.rb', line 32

def compound_operator
  string[0] == "=" ? nil : string[0...-1].to_sym
end

#operator_typeObject



28
29
30
# File 'lib/keisan/tokens/assignment.rb', line 28

def operator_type
  :"="
end