Class: Cardigan::Command::DestroyCards

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, io) ⇒ DestroyCards

Returns a new instance of DestroyCards.



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

def initialize repository, io
  @repository, @io = repository, io
  @usage = '<number>*'
  @help = 'Destroys 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/destroy_cards.rb', line 4

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



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

def usage
  @usage
end

Instance Method Details

#execute(numbers) ⇒ Object



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

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