Class: Assonnato::Show
- Inherits:
-
Object
- Object
- Assonnato::Show
- Includes:
- Parser
- Defined in:
- lib/assonnato/api/show.rb
Instance Method Summary collapse
- #all(status = :ongoing, options = {}) ⇒ Object
- #edit(name, episode, fields) ⇒ Object
- #get(show_name) ⇒ Object
-
#initialize(client) ⇒ Show
constructor
A new instance of Show.
- #last!(status) ⇒ Object
- #search(keyword) ⇒ Object
Methods included from Parser
Constructor Details
#initialize(client) ⇒ Show
Returns a new instance of Show.
13 14 15 |
# File 'lib/assonnato/api/show.rb', line 13 def initialize(client) @client = client end |
Instance Method Details
#all(status = :ongoing, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/assonnato/api/show.rb', line 17 def all(status = :ongoing, = {}) filters = ''.tap { |str| if .has_key? :fansub str << by_fansub([:fansub]) elsif .has_key? :user if .has_key? :role str << by_role([:user], [:role]) else str << by_staff([:user]) end end } parse @client.get("/api/v1/#{filters}/shows/all/#{status}") end |
#edit(name, episode, fields) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/assonnato/api/show.rb', line 45 def edit(name, episode, fields) path = '/api/v1/episode/edit' data = { name: name, episode: episode, _csrf: @client.user.csrf_token }.merge fields @client.post path, data end |
#get(show_name) ⇒ Object
33 34 35 |
# File 'lib/assonnato/api/show.rb', line 33 def get(show_name) search(show_name).select { |show| show.name == show_name } end |
#last!(status) ⇒ Object
37 38 39 |
# File 'lib/assonnato/api/show.rb', line 37 def last!(status) raise NotImplementedError, 'Show#last is not implemented' end |
#search(keyword) ⇒ Object
41 42 43 |
# File 'lib/assonnato/api/show.rb', line 41 def search(keyword) parse @client.get("/api/v1/shows/search/#{URI.escape keyword}") end |