Class: D3MPQ::ModCode::Stack::StackValue
- Inherits:
-
Object
- Object
- D3MPQ::ModCode::Stack::StackValue
- Defined in:
- lib/d3_mpq/mod_code.rb
Overview
Wrapper for a Float that handles: current_value, min_value, max_value
Instance Attribute Summary collapse
-
#min_max ⇒ Object
Returns the value of attribute min_max.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, min = nil, max = nil) ⇒ StackValue
constructor
A new instance of StackValue.
- #to_s ⇒ Object
Constructor Details
#initialize(value, min = nil, max = nil) ⇒ StackValue
Returns a new instance of StackValue.
171 172 173 174 175 |
# File 'lib/d3_mpq/mod_code.rb', line 171 def initialize(value, min = nil, max = nil) @value = value min ||= @value @min_max = MinMax.new(min, max) end |
Instance Attribute Details
#min_max ⇒ Object
Returns the value of attribute min_max.
165 166 167 |
# File 'lib/d3_mpq/mod_code.rb', line 165 def min_max @min_max end |
#value ⇒ Object
Returns the value of attribute value.
165 166 167 |
# File 'lib/d3_mpq/mod_code.rb', line 165 def value @value end |
Class Method Details
.random(min, max) ⇒ Object
167 168 169 |
# File 'lib/d3_mpq/mod_code.rb', line 167 def self.random(min, max) StackValue.new(MinMax.new(min.min, max.max).random, min.min, max.max) end |
Instance Method Details
#to_s ⇒ Object
182 183 184 |
# File 'lib/d3_mpq/mod_code.rb', line 182 def to_s (min == max) ? "#{min}" : "#{min}..#{max}" end |