Class: Fractify::OperatorArray

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

Instance Method Summary collapse

Instance Method Details

#sort_ascendingObject



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_descendingObject



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_sObject



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