Class: Gloo::Core::Op
- Inherits:
-
Object
- Object
- Gloo::Core::Op
- Defined in:
- lib/gloo/core/op.rb
Direct Known Subclasses
Class Method Summary collapse
-
.create_op(token) ⇒ Object
Create the operator for the given token.
-
.default_op ⇒ Object
Get the default operator (+).
-
.op?(token) ⇒ Boolean
Is the token an operator?.
Class Method Details
.create_op(token) ⇒ Object
Create the operator for the given token.
22 23 24 25 26 27 28 29 |
# File 'lib/gloo/core/op.rb', line 22 def self.create_op( token ) return Gloo::Expr::OpMinus.new if token == '-' return Gloo::Expr::OpMult.new if token == '*' return Gloo::Expr::OpDiv.new if token == '/' return Gloo::Expr::OpPlus.new if token == '+' return default_op end |
.default_op ⇒ Object
Get the default operator (+).
34 35 36 |
# File 'lib/gloo/core/op.rb', line 34 def self.default_op return Gloo::Expr::OpPlus.new end |
.op?(token) ⇒ Boolean
Is the token an operator?
15 16 17 |
# File 'lib/gloo/core/op.rb', line 15 def self.op?( token ) return [ '+', '-', '*', '/' ].include?( token.strip ) end |