Class: Cardigan::Command::ListCards

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, io) ⇒ ListCards

Returns a new instance of ListCards.



7
8
9
10
11
# File 'lib/cardigan/command/list_cards.rb', line 7

def initialize repository, io
  @repository, @io = repository, io
  @usage = ''
  @help = 'Lists all cards that match the current filter'
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



5
6
7
# File 'lib/cardigan/command/list_cards.rb', line 5

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



5
6
7
# File 'lib/cardigan/command/list_cards.rb', line 5

def usage
  @usage
end

Instance Method Details

#execute(text) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cardigan/command/list_cards.rb', line 13

def execute text
  cards = @repository.cards
  if cards.empty?
    @io.say "There are no cards to display"
    return
  end
  formatter = Cardigan::TextReportFormatter.new @io
  @repository.display_columns.each do |column|
    formatter.add_column(column, @repository.max_field_length(column))
  end
  formatter.output cards
end