Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/kibo/ext/ruby_ext.rb

Direct Known Subclasses

Kibo::Helpers::Info

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.diff(one, other) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/kibo/ext/ruby_ext.rb', line 2

def self.diff(one, other)
  one.zip(other).each do |ones, others|
    return 0 if ones.nil? && others.nil?
    
    return -1 if ones.nil?
    return 1 if others.nil?
    
    return -1 if ones < others
    return 1 if others < ones
  end
  
  return 0
end

Instance Method Details

#<(other) ⇒ Object



16
# File 'lib/kibo/ext/ruby_ext.rb', line 16

def < (other);  Array.diff(self, other) < 0; end

#<=(other) ⇒ Object



18
# File 'lib/kibo/ext/ruby_ext.rb', line 18

def <= (other); Array.diff(self, other) <= 0; end

#>(other) ⇒ Object



17
# File 'lib/kibo/ext/ruby_ext.rb', line 17

def > (other);  Array.diff(self, other) > 0; end

#>=(other) ⇒ Object



19
# File 'lib/kibo/ext/ruby_ext.rb', line 19

def >= (other); Array.diff(self, other) >= 0; end