Sha256: 4837acc5ed3829c3dd11eef68bae5b355349918034d0fd313ca88e34f732c647

Contents?: true

Size: 985 Bytes

Versions: 10

Compression:

Stored size: 985 Bytes

Contents

class Card
  class ActManager
    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, 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

      alias_method :delete_director, :delete

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

      def add_director dir
        add dir.card
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
card-1.20.4 lib/card/act_manager/subdirector_array.rb
card-1.20.3 lib/card/act_manager/subdirector_array.rb
card-1.20.2 lib/card/act_manager/subdirector_array.rb
card-1.20.1 lib/card/act_manager/subdirector_array.rb
card-1.20.0 lib/card/act_manager/subdirector_array.rb
card-1.19.6 lib/card/act_manager/subdirector_array.rb
card-1.19.5 lib/card/act_manager/subdirector_array.rb
card-1.19.4 lib/card/act_manager/subdirector_array.rb
card-1.19.3 lib/card/act_manager/subdirector_array.rb
card-1.19.2 lib/card/act_manager/subdirector_array.rb