Class: Wads::DataRange
- Inherits:
-
Object
- Object
- Wads::DataRange
- Defined in:
- lib/wads/data_structures.rb
Overview
A single dimension range, going from min to max. This class has helper methods to create bins within the given range.
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#min ⇒ Object
Returns the value of attribute min.
-
#range ⇒ Object
Returns the value of attribute range.
Instance Method Summary collapse
- #bin_max_values(number_of_bins) ⇒ Object
-
#initialize(min, max) ⇒ DataRange
constructor
A new instance of DataRange.
Constructor Details
#initialize(min, max) ⇒ DataRange
Returns a new instance of DataRange.
759 760 761 762 763 764 765 766 767 768 |
# File 'lib/wads/data_structures.rb', line 759 def initialize(min, max) if min < max @min = min @max = max else @min = max @max = min end @range = @max - @min end |
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
756 757 758 |
# File 'lib/wads/data_structures.rb', line 756 def max @max end |
#min ⇒ Object
Returns the value of attribute min.
755 756 757 |
# File 'lib/wads/data_structures.rb', line 755 def min @min end |
#range ⇒ Object
Returns the value of attribute range.
757 758 759 |
# File 'lib/wads/data_structures.rb', line 757 def range @range end |
Instance Method Details
#bin_max_values(number_of_bins) ⇒ Object
770 771 772 773 774 775 776 777 778 779 |
# File 'lib/wads/data_structures.rb', line 770 def bin_max_values(number_of_bins) bin_size = @range / number_of_bins.to_f bins = [] bin_start_value = @min number_of_bins.times do bin_start_value = bin_start_value + bin_size bins << bin_start_value end bins end |