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


146
147
148
149
150
151
152
153
# File 'lib/shoes/ruby.rb', line 146

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

#_clearObject


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

alias :_clear :clear

#_to_sObject


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

alias :_to_s :to_s

#clearObject


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

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

#clear_allObject


171
172
173
# File 'lib/shoes/ruby.rb', line 171

def clear_all
  self.each &:clear_all
end

#dark?Boolean

Returns:

  • (Boolean)

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

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

#light?Boolean

Returns:

  • (Boolean)

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

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

#to_sObject


176
177
178
# File 'lib/shoes/ruby.rb', line 176

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