Class: Ilp::Constant

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-cbc/ilp/constant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Constant

Returns a new instance of Constant.

Raises:

  • (ArgumentError)


4
5
6
7
# File 'lib/ruby-cbc/ilp/constant.rb', line 4

def initialize(value)
  raise ArgumentError, 'Argument is not numeric' unless value.is_a? Numeric
  @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/ruby-cbc/ilp/constant.rb', line 3

def value
  @value
end

Instance Method Details

#*(term) ⇒ Object



24
25
26
# File 'lib/ruby-cbc/ilp/constant.rb', line 24

def *(term)
  term * value
end

#+(term) ⇒ Object



28
29
30
# File 'lib/ruby-cbc/ilp/constant.rb', line 28

def +(term)
  term + value
end

#-(term) ⇒ Object



32
33
34
# File 'lib/ruby-cbc/ilp/constant.rb', line 32

def -(term)
  -1 * term + value
end

#<(term) ⇒ Object



11
12
13
# File 'lib/ruby-cbc/ilp/constant.rb', line 11

def <(term)
  term > value
end

#<=(term) ⇒ Object



8
9
10
# File 'lib/ruby-cbc/ilp/constant.rb', line 8

def <= (term)
  term >= value
end

#==(term) ⇒ Object



20
21
22
# File 'lib/ruby-cbc/ilp/constant.rb', line 20

def ==(term)
  term == value
end

#>(term) ⇒ Object



17
18
19
# File 'lib/ruby-cbc/ilp/constant.rb', line 17

def > (term)
  term < value
end

#>=(term) ⇒ Object



14
15
16
# File 'lib/ruby-cbc/ilp/constant.rb', line 14

def >=(term)
  term <= value
end

#pretty_printObject



40
41
42
# File 'lib/ruby-cbc/ilp/constant.rb', line 40

def pretty_print
  value.to_s
end

#to_sObject



36
37
38
# File 'lib/ruby-cbc/ilp/constant.rb', line 36

def to_s
  value.to_s
end