Class: R2do::Commands::DisplayCategoriesCommand
- Inherits:
-
R2do::Command
- Object
- R2do::Command
- R2do::Commands::DisplayCategoriesCommand
- Defined in:
- lib/r2do/commands/display_categories.rb
Instance Attribute Summary
Attributes inherited from R2do::Command
#description, #extended, #short
Instance Method Summary collapse
-
#execute(args) ⇒ void
Displays all the categories available.
- #help ⇒ Object
-
#initialize(state) ⇒ DisplayCategoriesCommand
constructor
A new instance of DisplayCategoriesCommand.
Methods inherited from R2do::Command
Constructor Details
#initialize(state) ⇒ DisplayCategoriesCommand
Returns a new instance of DisplayCategoriesCommand.
21 22 23 24 25 |
# File 'lib/r2do/commands/display_categories.rb', line 21 def initialize(state) super('l', 'list', 'Displays all the categories.') @state = state end |
Instance Method Details
#execute(args) ⇒ void
This method returns an undefined value.
Displays all the categories available
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/r2do/commands/display_categories.rb', line 31 def execute(args) if @state.categories.empty? UI.status("No categories to display") else @state.categories.each do |key, value| current = (value == @state.current_category && "*") || ' ' UI.status("#{current} #{value.name}") end end end |
#help ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/r2do/commands/display_categories.rb', line 42 def help() help = <<-EOF NAME r2do #{@extended} SYNOPSIS 'r2do #{@extended}' or 'r2do #{@short}' are equivalent DESCRIPTION The #{@extended} lets you Lists all the available categories in the application. The current selected category is marked with and asterisk '*' usage: r2do #{@extended} e.g. Category 1 * Category 2 Category 3 EOF end |