Sha256: a6adaff5df507a19eb718dc5886a22507139b8eda4fc981ee4c0c9917350a239

Contents?: true

Size: 887 Bytes

Versions: 6

Compression:

Stored size: 887 Bytes

Contents

class Card
  class SubdirectorArray < Array
    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

    def initialize parent
      @parent = parent
      super()
    end

    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

    alias_method :delete_director, :delete

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

    def add_director dir
      add dir.card
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
card-1.18.6 lib/card/subdirector_array.rb
card-1.18.5 lib/card/subdirector_array.rb
card-1.18.4 lib/card/subdirector_array.rb
card-1.18.3 lib/card/subdirector_array.rb
card-1.18.2 lib/card/subdirector_array.rb
card-1.18.1 lib/card/subdirector_array.rb