Class: Array

Inherits:
Object show all
Defined in:
lib/shoes/ruby.rb

Direct Known Subclasses

Hpricot::Elements

Instance Method Summary collapse

Instance Method Details

#/(len) ⇒ Object



135
136
137
138
139
140
141
142
# File 'lib/shoes/ruby.rb', line 135

def / len
  a = []
  each_with_index do |x, i|
    a << [] if i % len == 0
    a.last << x
  end
  a
end

#_clearObject



154
# File 'lib/shoes/ruby.rb', line 154

alias :_clear :clear

#_to_sObject



164
# File 'lib/shoes/ruby.rb', line 164

alias :_to_s :to_s

#clearObject



155
156
157
158
# File 'lib/shoes/ruby.rb', line 155

def clear
  self.each{|e| e.clear if e.class.method_defined? :clear}
  _clear
end

#clear_allObject



160
161
162
# File 'lib/shoes/ruby.rb', line 160

def clear_all
  self.each &:clear_all
end

#dark?Boolean

Returns:

  • (Boolean)


144
145
146
147
# File 'lib/shoes/ruby.rb', line 144

def dark?
  r, g, b = self
  r + g + b < 0x55 * 3
end

#light?Boolean

Returns:

  • (Boolean)


149
150
151
152
# File 'lib/shoes/ruby.rb', line 149

def light?
  r, g, b = self
  r + g + b > 0xAA * 3
end

#to_sObject



165
166
167
# File 'lib/shoes/ruby.rb', line 165

def to_s
  self.map(&:to_s)._to_s
end