Class: Quandl::Command::Tasks::List

Inherits:
Base
  • Object
show all
Defined in:
lib/quandl/command/tasks/list.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #options, #request_timer

Instance Method Summary collapse

Methods inherited from Base

#ask_yes_or_no, authenticated_users_only!, call, #call, command_name, configure, #current_user, #debug, description, disable!, disabled?, #error, #fatal, #force_yes?, #info, #initialize, #logger, options, #summarize, #summarize_hash, syntax, #table, #verbose?, warn_unauthenticated_users

Constructor Details

This class inherits a constructor from Quandl::Command::Tasks::Base

Instance Method Details

#executeObject



17
18
19
20
21
22
23
24
# File 'lib/quandl/command/tasks/list.rb', line 17

def execute
  # find dataset
  debug "search_params: #{search_params}"
  dataset = Quandl::Client::Dataset.where( search_params ).fetch
  codes = dataset.collect(&:full_code)
  # fail on errors
  info codes.join("\n")
end

#pageObject



36
37
38
# File 'lib/quandl/command/tasks/list.rb', line 36

def page
  options.page.to_i || 1
end

#search_paramsObject



26
27
28
29
30
31
32
33
34
# File 'lib/quandl/command/tasks/list.rb', line 26

def search_params
  search_params = {}
  search_params[:query] = options.match if options.match.present?
  search_params[:source_code] = options.source_code.to_s.upcase if options.source_code.present?
  search_params[:per_page] = options.limit if options.limit.present?
  search_params[:page] = page
  search_params[:self_search] = search_params[:source_code].present? ? false : true
  search_params
end