Class: Cardigan::Command::DestroyCards
- Inherits:
-
Object
- Object
- Cardigan::Command::DestroyCards
- Defined in:
- lib/cardigan/command/destroy_cards.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #execute(numbers) ⇒ Object
-
#initialize(repository, io) ⇒ DestroyCards
constructor
A new instance of DestroyCards.
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
#help ⇒ Object (readonly)
Returns the value of attribute help.
4 5 6 |
# File 'lib/cardigan/command/destroy_cards.rb', line 4 def help @help end |
#usage ⇒ Object (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 |