Class: Chimps::Commands::List
- Inherits:
-
Chimps::Command
- Object
- OptionParser
- Chimps::Command
- Chimps::Commands::List
- Includes:
- Utils::UsesModel
- Defined in:
- lib/chimps/commands/list.rb
Overview
A command to issue a GET request against an index of resources at Infochimps.
Constant Summary collapse
- BANNER =
"chimps list [OPTIONS]"- HELP =
"\nList resources of a given type (defaults to dataset).\n\nLists your resources by default but see options below.\n\n"- MODELS =
Models that can be indexed (default first)
%w[dataset license source]
Instance Attribute Summary
Attributes inherited from Chimps::Command
Instance Method Summary collapse
-
#all? ⇒ Boolean
List all resources or just those owned by the Chimps user?.
- #define_options ⇒ Object
-
#execute! ⇒ Object
Issue the GET request.
-
#params ⇒ Hash?
Parameters to include in the query.
Methods included from Utils::UsesModel
#define_model_option, #model, #model=, #model_identifier, #model_path, #models_path, #models_string, #plural_model
Methods inherited from Chimps::Command
Constructor Details
This class inherits a constructor from Chimps::Command
Instance Method Details
#all? ⇒ Boolean
List all resources or just those owned by the Chimps user?
33 34 35 |
# File 'lib/chimps/commands/list.rb', line 33 def all? @all end |
#define_options ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/chimps/commands/list.rb', line 21 def on_tail("-a", "--all", "List all resources, not just those owned by you.") do |a| @all = a end on_tail("-s", "--[no-]skip-column-names", "Don't print column names in output.") do |s| @skip_column_names = s end end |
#execute! ⇒ Object
Issue the GET request.
47 48 49 |
# File 'lib/chimps/commands/list.rb', line 47 def execute! Request.new(models_path, :params => params).get.print(:skip_column_names => @skip_column_names) end |
#params ⇒ Hash?
Parameters to include in the query.
If listing all resources, then return nil.
42 43 44 |
# File 'lib/chimps/commands/list.rb', line 42 def params return { :id => Chimps.username } unless all? end |