Class: Fractify::OperatorArray

Inherits:
Array
  • Object
show all
Defined in:
lib/fractify/operator_array.rb

Instance Method Summary collapse

Instance Method Details

#sort_ascendingObject



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_descendingObject



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_sObject



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