Class: Cardigan::Command::BatchUpdateCards
- Inherits:
-
Object
- Object
- Cardigan::Command::BatchUpdateCards
- Defined in:
- lib/cardigan/command/batch_update_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(text) ⇒ Object
-
#initialize(repository, io) ⇒ BatchUpdateCards
constructor
A new instance of BatchUpdateCards.
Constructor Details
#initialize(repository, io) ⇒ BatchUpdateCards
Returns a new instance of BatchUpdateCards.
7 8 9 10 11 |
# File 'lib/cardigan/command/batch_update_cards.rb', line 7 def initialize repository, io @repository, @io = repository, io @usage = '<field> <number>*' @help = 'Sets the specified field to a new value for the specified cards (by index in the list)' end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/cardigan/command/batch_update_cards.rb', line 5 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/cardigan/command/batch_update_cards.rb', line 5 def usage @usage end |
Instance Method Details
#execute(text) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cardigan/command/batch_update_cards.rb', line 13 def execute text key, *rest = text.scan(/\w+/) value = @io.ask("Enter the new value for #{key}") @repository.each_card_from_indices(rest.join(' ')) do |card| Cardigan::CardEditor.new(card, @io).set key, value @repository[card.id] = card end end |