Class: Ilp::Constant
- Inherits:
-
Object
- Object
- Ilp::Constant
- Defined in:
- lib/ruby-cbc/ilp/constant.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #*(term) ⇒ Object
- #+(term) ⇒ Object
- #-(term) ⇒ Object
- #<(term) ⇒ Object
- #<=(term) ⇒ Object
- #==(term) ⇒ Object
- #>(term) ⇒ Object
- #>=(term) ⇒ Object
-
#initialize(value) ⇒ Constant
constructor
A new instance of Constant.
- #pretty_print ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Constant
Returns a new instance of Constant.
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
#value ⇒ Object
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_print ⇒ Object
40 41 42 |
# File 'lib/ruby-cbc/ilp/constant.rb', line 40 def pretty_print value.to_s end |
#to_s ⇒ Object
36 37 38 |
# File 'lib/ruby-cbc/ilp/constant.rb', line 36 def to_s value.to_s end |