Class: ORTools::Product
- Inherits:
-
Expression
- Object
- Expression
- ORTools::Product
- Defined in:
- lib/or_tools/product.rb
Instance Attribute Summary collapse
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
Attributes included from ExpressionMethods
Instance Method Summary collapse
-
#initialize(left, right) ⇒ Product
constructor
A new instance of Product.
- #inspect ⇒ Object
- #vars ⇒ Object
Methods inherited from Expression
Methods included from ExpressionMethods
#!=, #*, #+, #-, #-@, #<, #<=, #==, #>, #>=, #coerce, #to_s
Constructor Details
#initialize(left, right) ⇒ Product
Returns a new instance of Product.
5 6 7 8 |
# File 'lib/or_tools/product.rb', line 5 def initialize(left, right) @left = left @right = right end |
Instance Attribute Details
#left ⇒ Object (readonly)
Returns the value of attribute left.
3 4 5 |
# File 'lib/or_tools/product.rb', line 3 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/or_tools/product.rb', line 3 def right @right end |
Instance Method Details
#inspect ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/or_tools/product.rb', line 10 def inspect if @left.is_a?(Constant) && @right.is_a?(Variable) && left.value == -1 "-#{inspect_part(@right)}" else "#{inspect_part(@left)} * #{inspect_part(@right)}" end end |
#vars ⇒ Object
18 19 20 |
# File 'lib/or_tools/product.rb', line 18 def vars @vars ||= (@left.vars + @right.vars).uniq end |