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

#*(other) ⇒ Object



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

def *(other)
  other * value
end

#+(other) ⇒ Object



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

def +(other)
  other + value
end

#-(other) ⇒ Object



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

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

#<(other) ⇒ Object



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

def <(other)
  other > value
end

#<=(other) ⇒ Object



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

def <=(other)
  other >= value
end

#==(other) ⇒ Object



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

def ==(other)
  other == value
end

#>(other) ⇒ Object



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

def >(other)
  other < value
end

#>=(other) ⇒ Object



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

def >=(other)
  other <= value
end

#pretty_printObject



45
46
47
# File 'lib/ruby-cbc/ilp/constant.rb', line 45

def pretty_print
  value.to_s
end

#to_sObject



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

def to_s
  value.to_s
end