Class: D3MPQ::ModCode::Stack::StackValue

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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_maxObject

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

#valueObject

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_sObject



182
183
184
# File 'lib/d3_mpq/mod_code.rb', line 182

def to_s
  (min == max) ? "#{min}" : "#{min}..#{max}"
end