Class: Fractify::OperatorArray
- Inherits:
-
Array
- Object
- Array
- Fractify::OperatorArray
- Defined in:
- lib/fractify/operator_array.rb
Instance Method Summary collapse
- #sort_ascending ⇒ Object
- #sort_ascending! ⇒ Object
- #sort_descending ⇒ Object
- #sort_descending! ⇒ Object
- #to_s ⇒ Object
Instance Method Details
#sort_ascending ⇒ Object
17 18 19 |
# File 'lib/fractify/operator_array.rb', line 17 def sort_ascending Fractify::OperatorArray.new(sort { |a, b| a <=> b }) end |
#sort_ascending! ⇒ Object
13 14 15 |
# File 'lib/fractify/operator_array.rb', line 13 def sort_ascending! sort! { |a, b| a <=> b } end |
#sort_descending ⇒ Object
9 10 11 |
# File 'lib/fractify/operator_array.rb', line 9 def sort_descending Fractify::OperatorArray.new(sort { |a, b| b <=> a }) end |
#sort_descending! ⇒ Object
5 6 7 |
# File 'lib/fractify/operator_array.rb', line 5 def sort_descending! sort! { |a, b| b <=> a } end |
#to_s ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/fractify/operator_array.rb', line 21 def to_s string = '' each do |a| string += a.to_s string += ', ' if a != last end string end |