Class: Given::BinaryOperation
- Inherits:
-
Object
- Object
- Given::BinaryOperation
- Defined in:
- lib/given/binary_operation.rb
Constant Summary collapse
- BINARY_EXPLAINATIONS =
{ :== => "to equal", :!= => "to not equal", :< => "to be less than", :<= => "to be less or equal to", :> => "to be greater than", :>= => "to be greater or equal to", :=~ => "to match", :!~ => "to not match", :=== => "to be matched by", }
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Class Method Summary collapse
Instance Method Summary collapse
- #explain ⇒ Object
-
#initialize(left, operator, right) ⇒ BinaryOperation
constructor
A new instance of BinaryOperation.
Constructor Details
#initialize(left, operator, right) ⇒ BinaryOperation
Returns a new instance of BinaryOperation.
18 19 20 21 22 |
# File 'lib/given/binary_operation.rb', line 18 def initialize(left, operator, right) @left = left @operator = operator @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
16 17 18 |
# File 'lib/given/binary_operation.rb', line 16 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
16 17 18 |
# File 'lib/given/binary_operation.rb', line 16 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
16 17 18 |
# File 'lib/given/binary_operation.rb', line 16 def right @right end |
Class Method Details
.parse(sexp) ⇒ Object
28 29 30 31 |
# File 'lib/given/binary_operation.rb', line 28 def self.parse(sexp) return nil unless sexp.first == :binary new(sexp[1], sexp[2], sexp[3]) end |
Instance Method Details
#explain ⇒ Object
24 25 26 |
# File 'lib/given/binary_operation.rb', line 24 def explain BINARY_EXPLAINATIONS[operator] end |