Class: Cardigan::Command::ClaimCards

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, io, name) ⇒ ClaimCards

Returns a new instance of ClaimCards.



6
7
8
9
10
# File 'lib/cardigan/command/claim_cards.rb', line 6

def initialize repository, io, name
  @repository, @io, @name = repository, io, name
  @usage = '<number>*'
  @help = 'Sets you as the owner of the specified cards (by index in the list)'
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



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

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



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

def usage
  @usage
end

Instance Method Details

#execute(numbers) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/cardigan/command/claim_cards.rb', line 12

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