Class: Card::SubdirectorArray

Inherits:
Array show all
Defined in:
lib/card/subdirector_array.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Array

#to_pointer_content

Constructor Details

#initialize(parent) ⇒ SubdirectorArray

Returns a new instance of SubdirectorArray.



11
12
13
14
# File 'lib/card/subdirector_array.rb', line 11

def initialize parent
  @parent = parent
  super()
end

Class Method Details

.initialize_with_subcards(parent) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/card/subdirector_array.rb', line 3

def self.initialize_with_subcards parent
  dir_array = new(parent)
  parent.card.subcards.each_card do |subcard|
    dir_array.add subcard
  end
  dir_array
end

Instance Method Details

#add(card) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/card/subdirector_array.rb', line 16

def add card
  if card.is_a? Card::StageDirector
    card = card.card
  end
  each do |dir|
    return dir if dir.card == card
  end
  dir = Card::DirectorRegister.fetch card, parent: @parent
  dir.main = false
  dir.parent = @parent
  self << dir
  dir
end

#add_director(dir) ⇒ Object



40
41
42
# File 'lib/card/subdirector_array.rb', line 40

def add_director dir
  add dir.card
end

#delete(card) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/card/subdirector_array.rb', line 32

def delete card
  if card.is_a? Card::StageDirector
    delete_director card
  else
    delete_if { |dir| dir.card == card }
  end
end

#delete_directorObject



30
# File 'lib/card/subdirector_array.rb', line 30

alias_method :delete_director, :delete