Class: Cassowary::Variable

Inherits:
AbstractVariable show all
Includes:
Equalities
Defined in:
lib/variables/variable.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractVariable

#name

Instance Method Summary collapse

Methods included from Equalities

#cn_equal, #cn_geq, #cn_leq

Methods inherited from AbstractVariable

#dummy?

Constructor Details

#initialize(hash) ⇒ Variable

Returns a new instance of Variable.



9
10
11
12
# File 'lib/variables/variable.rb', line 9

def initialize(hash)
  super
  self.value = hash[:value]
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/variables/variable.rb', line 7

def value
  @value
end

Instance Method Details

#*(expr) ⇒ Object



14
15
16
# File 'lib/variables/variable.rb', line 14

def *(expr)
  self.as_linear_expression * expr
end

#+(expr) ⇒ Object



18
19
20
# File 'lib/variables/variable.rb', line 18

def +(expr)
  self.as_linear_expression + expr
end

#-(expr) ⇒ Object



22
23
24
# File 'lib/variables/variable.rb', line 22

def -(expr)
  self.as_linear_expression - expr
end

#-@Object



48
49
50
# File 'lib/variables/variable.rb', line 48

def -@
  -1.0.as_linear_expression * self
end

#/(expr) ⇒ Object



26
27
28
# File 'lib/variables/variable.rb', line 26

def /(expr)
  self.as_linear_expression / expr
end

#as_linear_expressionObject



30
31
32
33
34
# File 'lib/variables/variable.rb', line 30

def as_linear_expression
  expr = LinearExpression.new
  expr.terms[self] = 1.0
  expr
end

#external?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/variables/variable.rb', line 36

def external?
  true
end

#inspectObject



52
53
54
# File 'lib/variables/variable.rb', line 52

def inspect
  "#{super}[#{value.inspect}]"
end

#pivotable?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/variables/variable.rb', line 40

def pivotable?
  false
end

#restricted?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/variables/variable.rb', line 44

def restricted?
  false
end