Class: Beats::Command::Api
- Inherits:
-
Base
- Object
- Base
- Beats::Command::Api
show all
- Defined in:
- lib/beats/commands/api.rb
Instance Attribute Summary
Attributes inherited from Base
#args
Instance Method Summary
collapse
Methods inherited from Base
has_command?, #initialize
Instance Method Details
#info ⇒ Object
5
6
7
|
# File 'lib/beats/commands/api.rb', line 5
def info
display YAML.dump(client.index)
end
|
#search ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/beats/commands/api.rb', line 19
def search
interactive do |args|
query = args.join(' AND ')
display "Searching for: \"#{query}\""
results = client.search(query)
display "#{results['total']} item(s) found"
%w(artists albums tracks).each do |collection|
next unless results[collection].is_a?(Array)
display_resources(results[collection])
end
end
end
|
#show ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/beats/commands/api.rb', line 9
def show
if args.empty?
raise CommandFailed, command_usage('show', 'URI [...]')
else
display_resources(args.map { |uri|
client.resource(CGI.escape(uri))
})
end
end
|