Class: Wassup::PaneBuilder::ContentBuilder
- Inherits:
-
Object
- Object
- Wassup::PaneBuilder::ContentBuilder
- Defined in:
- lib/wassup/pane_builder.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
Instance Method Summary collapse
- #add_row(display, object = nil, page: nil) ⇒ Object
- #clear=(clear) ⇒ Object
-
#initialize(contents) ⇒ ContentBuilder
constructor
A new instance of ContentBuilder.
Constructor Details
#initialize(contents) ⇒ ContentBuilder
Returns a new instance of ContentBuilder.
34 35 36 37 38 |
# File 'lib/wassup/pane_builder.rb', line 34 def initialize(contents) @contents = contents @need_to_clear = true @show_refresh = true end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
32 33 34 |
# File 'lib/wassup/pane_builder.rb', line 32 def contents @contents end |
Instance Method Details
#add_row(display, object = nil, page: nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/wassup/pane_builder.rb', line 44 def add_row(display, object=nil, page:nil) if @need_to_clear @need_to_clear = false self.contents = [] end content = nil # Create contents if none if page.nil? if self.contents.empty? content = Pane::Content.new self.contents << content else content = self.contents.first end elsif page.is_a?(String) content = self.contents.find do |content| content.title == page end if content.nil? content = Pane::Content.new(page) self.contents << content end end content.add_row(display, object) end |
#clear=(clear) ⇒ Object
40 41 42 |
# File 'lib/wassup/pane_builder.rb', line 40 def clear=(clear) @need_to_clear = clear end |