Class: Cardigan::Command::UnclaimCards

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, io) ⇒ UnclaimCards

Returns a new instance of UnclaimCards.



4
5
6
7
8
# File 'lib/cardigan/command/unclaim_cards.rb', line 4

def initialize repository, io
  @repository, @io = repository, io
  @usage = '<number> [<number]*'
  @help = 'Removes the owner of the specified cards'
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



2
3
4
# File 'lib/cardigan/command/unclaim_cards.rb', line 2

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



2
3
4
# File 'lib/cardigan/command/unclaim_cards.rb', line 2

def usage
  @usage
end

Instance Method Details

#execute(numbers) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/cardigan/command/unclaim_cards.rb', line 10

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