Class: ORTools::Constant

Inherits:
Expression show all
Defined in:
lib/or_tools/constant.rb

Instance Attribute Summary collapse

Attributes included from ExpressionMethods

#parts

Instance Method Summary collapse

Methods inherited from Expression

to_expression

Methods included from ExpressionMethods

#!=, #*, #-, #<, #<=, #==, #>, #>=, #coerce, #to_s

Constructor Details

#initialize(value) ⇒ Constant

Returns a new instance of Constant.



5
6
7
# File 'lib/or_tools/constant.rb', line 5

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/or_tools/constant.rb', line 3

def value
  @value
end

Instance Method Details

#+(other) ⇒ Object

simplify Ruby sum



10
11
12
# File 'lib/or_tools/constant.rb', line 10

def +(other)
  @value == 0 ? other : super
end

#-@Object



18
19
20
# File 'lib/or_tools/constant.rb', line 18

def -@
  Constant.new(-value)
end

#inspectObject



14
15
16
# File 'lib/or_tools/constant.rb', line 14

def inspect
  @value.to_s
end

#varsObject



22
23
24
# File 'lib/or_tools/constant.rb', line 22

def vars
  @vars ||= []
end