Class: Array

Inherits:
Object show all
Defined in:
lib/hobo_support/array.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wrap(object) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/hobo_support/array.rb', line 22

def self.wrap(object)
  case object
  when nil
    []
  when self
    object
  else
    if object.respond_to?(:to_ary)
      object.to_ary
    else
      [object]
    end
  end
end

Instance Method Details

#*(rhs = nil) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/hobo_support/array.rb', line 5

def *(rhs=nil)
  if rhs
    multiply(rhs)
  else
    Enumerable::MultiSender.new(self, :map)
  end
end

#drop_while!Object



13
14
15
16
17
18
# File 'lib/hobo_support/array.rb', line 13

def drop_while!
  drop = 0
  drop += 1 while yield(self[drop])
  self[0..drop-1] = []
  self
end

#multiplyObject



3
# File 'lib/hobo_support/array.rb', line 3

alias_method :multiply, :*