Class: Cardigan::Command::ClaimCards

Inherits:
Object
  • Object
show all
Defined in:
lib/cardigan/command/claim_cards.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository, io, name) ⇒ ClaimCards

Returns a new instance of ClaimCards.



4
5
6
# File 'lib/cardigan/command/claim_cards.rb', line 4

def initialize repository, io, name
  @repository, @io, @name = repository, io, name
end

Instance Method Details

#execute(numbers) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/cardigan/command/claim_cards.rb', line 8

def execute numbers
  @repository.each_card_from_indices(numbers) do |card|
    @io.say "claiming \"#{card['name']}\""
    card['owner'] = @name
    @repository.save card
  end
end