Class: MyShows::Profile

Inherits:
Object
  • Object
show all
Defined in:
lib/myshows/profile.rb

Overview

Profile initialization is needed to gain access to some functions of API

Instance Method Summary collapse

Constructor Details

#initialize(login, password_md5) ⇒ Profile

Login and md5-hashed password of valid account on myshows.ru



11
12
13
14
15
# File 'lib/myshows/profile.rb', line 11

def initialize(, password_md5)
  @api = MyShows::API.instance

  @api.authorize , password_md5
end

Instance Method Details

#show(title) ⇒ Object

Smart search of one of user shows by title



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/myshows/profile.rb', line 24

def show(title)
  found = shows.values_at *matcher.match(title)
  case found.count
  when 0
    raise MyShows::Error.new "show with title \"#{title}\" was not found"
  when 1
    found.first
  else
    raise MyShows::Error.new "ambiguous title \"#{title}\" corresponds to shows #{found.map {|s| %Q["#{s}"]} * ', '}"
  end
end

#showsObject

All active, delayed and cancelled shows of current user



19
20
21
# File 'lib/myshows/profile.rb', line 19

def shows
  @api.user_shows
end