Class: Shoes::SlotContents
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Shoes::SlotContents
- Includes:
- Common::Inspect
- Defined in:
- shoes-core/lib/shoes/slot_contents.rb
Instance Method Summary collapse
- #add_element(element) ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ SlotContents
constructor
A new instance of SlotContents.
- #prepend ⇒ Object
- #prepending? ⇒ Boolean
Methods included from Common::Inspect
Constructor Details
#initialize ⇒ SlotContents
Returns a new instance of SlotContents.
7 8 9 10 11 12 |
# File 'shoes-core/lib/shoes/slot_contents.rb', line 7 def initialize @contents = [] @prepending = false @prepending_index = 0 super(@contents) end |
Instance Method Details
#add_element(element) ⇒ Object
18 19 20 21 22 23 24 |
# File 'shoes-core/lib/shoes/slot_contents.rb', line 18 def add_element(element) if @prepending prepend_element element else append_element element end end |
#clear ⇒ Object
33 34 35 36 37 38 |
# File 'shoes-core/lib/shoes/slot_contents.rb', line 33 def clear # reverse_each is important as otherwise we always miss to delete one # element @contents.reverse_each(&:remove) @contents.clear end |
#prepend ⇒ Object
26 27 28 29 30 31 |
# File 'shoes-core/lib/shoes/slot_contents.rb', line 26 def prepend @prepending_index = 0 @prepending = true yield if block_given? @prepending = false end |
#prepending? ⇒ Boolean
14 15 16 |
# File 'shoes-core/lib/shoes/slot_contents.rb', line 14 def prepending? @prepending end |