Class: Card::Director::SubdirectorArray

Inherits:
Array
  • Object
show all
Defined in:
lib/card/director/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/director/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/director/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) ⇒ Object



17
18
19
20
# File 'lib/card/director/subdirector_array.rb', line 17

def add card
  card = card.card if card.is_a? Director
  existing(card) || fetch_new(card)
end

#delete(card) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/card/director/subdirector_array.rb', line 24

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

#delete_directorObject



22
# File 'lib/card/director/subdirector_array.rb', line 22

alias_method :delete_director, :delete