Class: Shoes::SlotContents

Inherits:
SimpleDelegator
  • Object
show all
Includes:
Common::Inspect
Defined in:
shoes-core/lib/shoes/slot_contents.rb

Instance Method Summary collapse

Methods included from Common::Inspect

#inspect, #to_s

Constructor Details

#initializeSlotContents

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

#clearObject



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

#prependObject



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

Returns:

  • (Boolean)


14
15
16
# File 'shoes-core/lib/shoes/slot_contents.rb', line 14

def prepending?
  @prepending
end