Class: Opt::Constant
- Inherits:
-
Expression
- Object
- Expression
- Opt::Constant
- Defined in:
- lib/opt/constant.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Expression
Instance Method Summary collapse
-
#+(other) ⇒ Object
simplify Ruby sum.
- #-@ ⇒ Object
-
#initialize(value) ⇒ Constant
constructor
A new instance of Constant.
- #inspect ⇒ Object
- #vars ⇒ Object
Methods inherited from Expression
#*, #-, #<, #<=, #==, #>, #>=, #coerce, to_expression
Constructor Details
#initialize(value) ⇒ Constant
5 6 7 |
# File 'lib/opt/constant.rb', line 5 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/opt/constant.rb', line 3 def value @value end |
Instance Method Details
#+(other) ⇒ Object
simplify Ruby sum
10 11 12 |
# File 'lib/opt/constant.rb', line 10 def +(other) @value == 0 ? other : super end |
#-@ ⇒ Object
18 19 20 |
# File 'lib/opt/constant.rb', line 18 def -@ Constant.new(-value) end |
#inspect ⇒ Object
14 15 16 |
# File 'lib/opt/constant.rb', line 14 def inspect @value.to_s end |
#vars ⇒ Object
22 23 24 |
# File 'lib/opt/constant.rb', line 22 def vars @vars ||= [] end |