Class: Array

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

Instance Method Summary collapse

Instance Method Details

#/(len) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/shoes/inspect.rb', line 43

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

#inspect(hits = {}) ⇒ Object



26
27
28
29
30
# File 'lib/shoes/inspect.rb', line 26

def inspect(hits = {})
    return "[...]" if hits[self]
    hits[self] = true
    "[" + map { |x| x.method(:inspect).arity == 0 ? x.inspect : x.inspect(hits) }.join(', ') + "]"
end

#to_htmlObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/shoes/inspect.rb', line 31

def to_html
  ary = self
  Web.Bit {
    h5 "A List of Things"
    h1 "An Array"
    unless ary.empty?
      ol {
        ary.map { |x| li { self << HTML(x) } }
      }
    end
  }
end