class Assonnato::Show
Public Class Methods
new(client)
click to toggle source
# File lib/assonnato/api/show.rb, line 13 def initialize(client) @client = client end
Public Instance Methods
all(status = :ongoing, options = {})
click to toggle source
# File lib/assonnato/api/show.rb, line 17 def all(status = :ongoing, options = {}) filters = ''.tap { |str| if options.has_key? :fansub str << by_fansub(options[:fansub]) elsif options.has_key? :user if options.has_key? :role str << by_role(options[:user], options[:role]) else str << by_staff(options[:user]) end end } parse @client.get("/api/v1/#{filters}/shows/all/#{status}") end
edit(name, episode, fields)
click to toggle source
# 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)
click to toggle source
# File lib/assonnato/api/show.rb, line 33 def get(show_name) search(show_name).select { |show| show.name == show_name } end
last!(status)
click to toggle source
# File lib/assonnato/api/show.rb, line 37 def last!(status) raise NotImplementedError, 'Show#last is not implemented' end
search(keyword)
click to toggle source
# File lib/assonnato/api/show.rb, line 41 def search(keyword) parse @client.get("/api/v1/shows/search/#{URI.escape keyword}") end
Private Instance Methods
by_fansub(fansub)
click to toggle source
# File lib/assonnato/api/show.rb, line 53 def by_fansub(fansub) "/fansubs/#{URI.escape fansub}" end
by_role(user, role)
click to toggle source
# File lib/assonnato/api/show.rb, line 63 def by_role(user, role) "/users/#{URI.escape user}/#{role}" end
by_staff(user)
click to toggle source
# File lib/assonnato/api/show.rb, line 58 def by_staff(user) "/users/#{URI.escape user}" end