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
- #*(other) ⇒ Object
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ 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
#*(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_print ⇒ Object
45 46 47 |
# File 'lib/ruby-cbc/ilp/constant.rb', line 45 def pretty_print value.to_s end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/ruby-cbc/ilp/constant.rb', line 41 def to_s value.to_s end |