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
18 19 20 |
# File 'lib/fractify/operator_array.rb', line 18 def sort_ascending Fractify::OperatorArray.new(sort { |a, b| a <=> b }) end |
#sort_ascending! ⇒ Object
14 15 16 |
# File 'lib/fractify/operator_array.rb', line 14 def sort_ascending! sort! { |a, b| a <=> b } end |
#sort_descending ⇒ Object
10 11 12 |
# File 'lib/fractify/operator_array.rb', line 10 def sort_descending Fractify::OperatorArray.new(sort { |a, b| b <=> a }) end |
#sort_descending! ⇒ Object
6 7 8 |
# File 'lib/fractify/operator_array.rb', line 6 def sort_descending! sort! { |a, b| b <=> a } end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/fractify/operator_array.rb', line 22 def to_s string = '' each do |a| string += a.to_s string += ', ' if a != last end string end |