Class: Card::ActManager::SubdirectorArray

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ SubdirectorArray

Returns a new instance of SubdirectorArray.



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

def initialize parent
  @parent = parent
  super()
end

Class Method Details

.initialize_with_subcards(parent) ⇒ Object



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

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, opts = {}) ⇒ Object



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

def add card, opts={}
  opts ||= {}
  card = card.card if card.is_a? StageDirector
  each { |dir| return dir if dir.card == card }
  dir = ActManager.fetch card, parent: @parent
  dir.main = false
  dir.parent = @parent
  dir.transact_in_stage = opts[:transact_in_stage]
  self << dir
  dir
end

#add_director(dir) ⇒ Object



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

def add_director dir
  add dir.card
end

#delete(card) ⇒ Object



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

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

#delete_directorObject



29
# File 'lib/card/act_manager/subdirector_array.rb', line 29

alias_method :delete_director, :delete