Class: ORTools::Expression

Inherits:
Object
  • Object
show all
Includes:
ExpressionMethods
Defined in:
lib/or_tools/expression.rb

Direct Known Subclasses

Constant, Product

Instance Attribute Summary

Attributes included from ExpressionMethods

#parts

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ExpressionMethods

#!=, #*, #+, #-, #-@, #<, #<=, #==, #>, #>=, #coerce, #inspect, #to_s, #vars

Constructor Details

#initialize(parts = []) ⇒ Expression

Returns a new instance of Expression.



70
71
72
# File 'lib/or_tools/expression.rb', line 70

def initialize(parts = [])
  @parts = parts
end

Class Method Details

.to_expression(other) ⇒ Object

private



75
76
77
78
79
80
81
82
83
# File 'lib/or_tools/expression.rb', line 75

def self.to_expression(other)
  if other.is_a?(Numeric)
    Constant.new(other)
  elsif other.is_a?(Variable) || other.is_a?(Expression)
    other
  else
    raise TypeError, "can't cast #{other.class.name} to Expression"
  end
end