Class: Holivia::Commands::Objective
- Defined in:
- lib/holivia/commands/objective.rb
Constant Summary collapse
- BASE_PATH =
"/api/v1/backoffice/objectives"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.route(args) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/holivia/commands/objective.rb', line 10 def self.route(args) subcommand = args.shift case subcommand when "index" then new.index(args) when "show" then new.show(args) else warn "Unknown objective command: #{subcommand}" exit 1 end end |
Instance Method Details
#index(args = []) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/holivia/commands/objective.rb', line 20 def index(args = []) params = {} OptionParser.new do |opts| opts. = "Usage: holivia objective index [options]" opts.on("--page N", Integer) { |v| params[:page] = v } opts.on("--per-page N", Integer) { |v| params[:per_page] = v } opts.on("--code CODE") { |v| params[:code] = v } end.parse!(args) output(client.get(BASE_PATH, params: params)) end |
#show(args = []) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/holivia/commands/objective.rb', line 32 def show(args = []) id = args.shift abort "Usage: holivia objective show <id>" unless id output(client.get("#{BASE_PATH}/#{id}")) end |