Class: Opt::Variable
- Inherits:
-
Expression
- Object
- Expression
- Opt::Variable
- Defined in:
- lib/opt/variable.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bounds ⇒ Object
readonly
Returns the value of attribute bounds.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Expression
Instance Method Summary collapse
-
#initialize(bounds, name = nil) ⇒ Variable
constructor
A new instance of Variable.
- #inspect ⇒ Object
- #vars ⇒ Object
Methods inherited from Expression
#*, #+, #-, #-@, #<, #<=, #==, #>, #>=, #coerce, to_expression
Constructor Details
#initialize(bounds, name = nil) ⇒ Variable
Returns a new instance of Variable.
6 7 8 9 |
# File 'lib/opt/variable.rb', line 6 def initialize(bounds, name = nil) @bounds = bounds @name = name || "x#{object_id}" end |
Instance Attribute Details
#bounds ⇒ Object (readonly)
Returns the value of attribute bounds.
3 4 5 |
# File 'lib/opt/variable.rb', line 3 def bounds @bounds end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/opt/variable.rb', line 3 def name @name end |
#value ⇒ Object
Returns the value of attribute value.
4 5 6 |
# File 'lib/opt/variable.rb', line 4 def value @value end |
Instance Method Details
#inspect ⇒ Object
11 12 13 |
# File 'lib/opt/variable.rb', line 11 def inspect @name end |
#vars ⇒ Object
15 16 17 |
# File 'lib/opt/variable.rb', line 15 def vars @vars ||= [self] end |