Class: Kanye::Page
- Inherits:
-
Object
- Object
- Kanye::Page
- Defined in:
- lib/kanye/page.rb
Instance Attribute Summary collapse
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#tracks ⇒ Object
readonly
Returns the value of attribute tracks.
Instance Method Summary collapse
- #download_all! ⇒ Object
-
#initialize(path, page = 1) ⇒ Page
constructor
A new instance of Page.
- #url(path, page = 1) ⇒ Object
Constructor Details
#initialize(path, page = 1) ⇒ Page
Returns a new instance of Page.
6 7 8 9 10 11 12 |
# File 'lib/kanye/page.rb', line 6 def initialize(path, page=1) @response = HTTParty.get url(path, page) @tracks = [] @cookie = @response.headers['set-cookie'] @html = @response.parsed_response parse_response end |
Instance Attribute Details
#html ⇒ Object (readonly)
Returns the value of attribute html.
3 4 5 |
# File 'lib/kanye/page.rb', line 3 def html @html end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
3 4 5 |
# File 'lib/kanye/page.rb', line 3 def response @response end |
#tracks ⇒ Object (readonly)
Returns the value of attribute tracks.
3 4 5 |
# File 'lib/kanye/page.rb', line 3 def tracks @tracks end |
Instance Method Details
#download_all! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/kanye/page.rb', line 14 def download_all! tracks.each do |current_track| history = History.new(DEFAULT_DB_PATH) unless history.exists?(current_track) begin current_track.download! rescue Mp3InfoError => e print e. end history.insert(current_track) puts "\tInserted song into db" if Kanye.config["debug"] end end end |
#url(path, page = 1) ⇒ Object
30 31 32 |
# File 'lib/kanye/page.rb', line 30 def url(path, page=1) "http://#{BASE_URL}/"+path+"/"+page.to_s+"?ax=1&ts="+ end |