Class: Sangi::Expression
- Inherits:
-
Object
- Object
- Sangi::Expression
- Defined in:
- lib/sangi/expression.rb
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.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #effective_right ⇒ Object
-
#initialize(left:, operator:, right:, source:) ⇒ Expression
constructor
A new instance of Expression.
- #normalized_source ⇒ Object
Constructor Details
#initialize(left:, operator:, right:, source:) ⇒ Expression
Returns a new instance of Expression.
5 6 7 8 9 10 |
# File 'lib/sangi/expression.rb', line 5 def initialize(left:, operator:, right:, source:) @left = left @operator = operator @right = right @source = source end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
3 4 5 |
# File 'lib/sangi/expression.rb', line 3 def left @left end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
3 4 5 |
# File 'lib/sangi/expression.rb', line 3 def operator @operator end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/sangi/expression.rb', line 3 def right @right end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/sangi/expression.rb', line 3 def source @source end |
Instance Method Details
#effective_right ⇒ Object
12 13 14 |
# File 'lib/sangi/expression.rb', line 12 def effective_right operator == :- ? -right : right end |
#normalized_source ⇒ Object
16 17 18 |
# File 'lib/sangi/expression.rb', line 16 def normalized_source "#{left} + #{effective_right}" end |