Class: BOB::ChildArray
- Inherits:
-
Object
- Object
- BOB::ChildArray
- Defined in:
- lib/BOB/child_array.rb
Instance Method Summary collapse
- #a(data, options = nil) ⇒ Object
- #append(data, options = nil) ⇒ Object
- #cl(object_class) ⇒ Object
- #classs(object_class) ⇒ Object
- #co(content) ⇒ Object
-
#content(content) ⇒ Object
No point in doing this on parent.
- #d(data) ⇒ Object
-
#do(data) ⇒ Object
TODO: do(data).do(data2) does not behave correctly.
- #i(data, options = nil) ⇒ Object
- #id(object_id) ⇒ Object
-
#initialize(dataset, parent) ⇒ ChildArray
constructor
A new instance of ChildArray.
- #insert(data, options = nil) ⇒ Object
- #p(data, options = nil) ⇒ Object
- #pp ⇒ Object
- #prepend(data, options = nil) ⇒ Object
- #prettyPrint ⇒ Object
- #s(pretty = false) ⇒ Object
- #st(style) ⇒ Object
- #style(style) ⇒ Object
- #toString ⇒ Object
- #u ⇒ Object
- #up ⇒ Object
Constructor Details
#initialize(dataset, parent) ⇒ ChildArray
Returns a new instance of ChildArray.
3 4 5 6 7 |
# File 'lib/BOB/child_array.rb', line 3 def initialize (dataset, parent) @dataset = dataset @parent = parent @bobs = [] end |
Instance Method Details
#a(data, options = nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/BOB/child_array.rb', line 65 def a (data, =nil) @dataset.each_with_index do |item, i| BOB::Element.data = item if @bobs[i] @bobs[i] = @bobs[i].a(data, ) else @bobs.push(@parent.a(data, )) end end return self end |
#append(data, options = nil) ⇒ Object
62 63 64 |
# File 'lib/BOB/child_array.rb', line 62 def append (data, =nil) self.a(data, ) end |
#cl(object_class) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/BOB/child_array.rb', line 33 def cl (object_class) @dataset.each_with_index do |item, i| BOB::Element.data = item @bobs[i].cl(object_class) if @bobs[i] end return self end |
#classs(object_class) ⇒ Object
30 31 32 |
# File 'lib/BOB/child_array.rb', line 30 def classs (object_class) self.cl(object_class) end |
#co(content) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/BOB/child_array.rb', line 13 def co (content) @dataset.each_with_index do |item, i| BOB::Element.data = item @bobs[i].co(content) if @bobs[i] end return self end |
#content(content) ⇒ Object
No point in doing this on parent. Does not make sense to do “.do(data).id(BOB::Element.data)”
10 11 12 |
# File 'lib/BOB/child_array.rb', line 10 def content (content) self.co(content) end |
#d(data) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/BOB/child_array.rb', line 118 def d (data) for bob in @bobs BOB::Element.data = item if @bobs[i] @bobs[i] = @bobs[i].d(data) else @bobs.push(@parent.d(data)) end end return self end |
#do(data) ⇒ Object
TODO: do(data).do(data2) does not behave correctly
115 116 117 |
# File 'lib/BOB/child_array.rb', line 115 def do (data) self.d(data) end |
#i(data, options = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/BOB/child_array.rb', line 50 def i (data, =nil) @dataset.each_with_index do |item, i| BOB::Element.data = item if @bobs[i] @bobs[i] = @bobs[i].insert(data, ) else @bobs.push(@parent.insert(data, )) end end return self end |
#id(object_id) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/BOB/child_array.rb', line 40 def id (object_id) @dataset.each_with_index do |item, i| BOB::Element.data = item @bobs[i].id(object_id) if @bobs[i] end return self end |
#insert(data, options = nil) ⇒ Object
47 48 49 |
# File 'lib/BOB/child_array.rb', line 47 def insert (data, =nil) self.i(data, ) end |
#p(data, options = nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/BOB/child_array.rb', line 80 def p (data, =nil) @dataset.each_with_index do |item, i| BOB::Element.data = item if @bobs[i] @bobs[i] = @bobs[i].p(data, ) else @bobs.push(@parent.p(data, )) end end return self end |
#pp ⇒ Object
95 96 97 |
# File 'lib/BOB/child_array.rb', line 95 def pp self.s(true) end |
#prepend(data, options = nil) ⇒ Object
77 78 79 |
# File 'lib/BOB/child_array.rb', line 77 def prepend (data, =nil) self.p(data, ) end |
#prettyPrint ⇒ Object
92 93 94 |
# File 'lib/BOB/child_array.rb', line 92 def prettyPrint self.pp() end |
#s(pretty = false) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/BOB/child_array.rb', line 101 def s (pretty = false) if @parent return @parent.s(pretty) else html_string = "" for bob in @bobs bob.parent = false html_string += bob.s(pretty) end return html_string end end |
#st(style) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/BOB/child_array.rb', line 23 def st (style) @dataset.each_with_index do |item, i| BOB::Element.data = item @bobs[i].st(style) if @bobs[i] end return self end |
#style(style) ⇒ Object
20 21 22 |
# File 'lib/BOB/child_array.rb', line 20 def style (style) self.st(style) end |
#toString ⇒ Object
98 99 100 |
# File 'lib/BOB/child_array.rb', line 98 def toString self.s() end |
#u ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/BOB/child_array.rb', line 133 def u unless @bobs[0] BOB::Element.data = nil return @parent end [0...@bobs.length].each do |i| @bobs[i] = @bobs[i].u() end if @bobs[0] == @parent BOB::Element.data = nil return @parent else return self end end |
#up ⇒ Object
130 131 132 |
# File 'lib/BOB/child_array.rb', line 130 def up self.u() end |