Class: Keisan::Tokens::LogicalOperator
- Inherits:
-
Operator
- Object
- Keisan::Token
- Operator
- Keisan::Tokens::LogicalOperator
- Defined in:
- lib/keisan/tokens/logical_operator.rb
Constant Summary collapse
- LESS_THAN_OR_EQUAL_TO =
/(?:\<\=)/
- GREATER_THAN_OR_EQUAL_TO =
/(?:\>\=)/
- LESS_THAN =
/(?:\<)/
- GREATER_THAN =
/(?:\>)/
- AND =
/(?:\&\&)/
- OR =
/(?:\|\|)/
- EQUAL =
/(?:\=\=)/
- NOT_EQUAL =
/(?:\!\=)/
- NOT =
/(?:\!+)/
- REGEX =
/(#{LESS_THAN_OR_EQUAL_TO}|#{GREATER_THAN_OR_EQUAL_TO}|#{LESS_THAN}|#{GREATER_THAN}|#{AND}|#{OR}|#{EQUAL}|#{NOT_EQUAL}|#{NOT})/
Instance Attribute Summary
Attributes inherited from Keisan::Token
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Operator
Methods inherited from Keisan::Token
#initialize, #regex, #type, type
Constructor Details
This class inherits a constructor from Keisan::Token
Class Method Details
.regex ⇒ Object
16 17 18 |
# File 'lib/keisan/tokens/logical_operator.rb', line 16 def self.regex REGEX end |
Instance Method Details
#operator_type ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/keisan/tokens/logical_operator.rb', line 20 def operator_type case string when LESS_THAN_OR_EQUAL_TO :<= when GREATER_THAN_OR_EQUAL_TO :>= when LESS_THAN :< when GREATER_THAN :> when AND :"&&" when OR :"||" when EQUAL :"==" when NOT_EQUAL :"!=" when NOT string.count("!").even? ? :"!!" : :"!" end end |