Class: ExUA::Item
- Inherits:
-
Struct
- Object
- Struct
- ExUA::Item
- Defined in:
- lib/ex_ua/item.rb
Overview
Download item
Instance Attribute Summary collapse
-
#additional_servers ⇒ Object
Returns the value of attribute additional_servers.
-
#id ⇒ Object
Returns the value of attribute id.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #download_uri ⇒ Object
-
#get_uri ⇒ Object
Actual download url with ex.ua included You can add ?fs_id=server_id param to download form #additional_servers @return.
- #retrieve_real_get_url ⇒ Object
-
#retrieve_real_load_url ⇒ Object
Queries ex.ua to get a real url to fetch data from (follows redirect).
Instance Attribute Details
#additional_servers ⇒ Object
Returns the value of attribute additional_servers
5 6 7 |
# File 'lib/ex_ua/item.rb', line 5 def additional_servers @additional_servers end |
#id ⇒ Object
Returns the value of attribute id
5 6 7 |
# File 'lib/ex_ua/item.rb', line 5 def id @id end |
#title ⇒ Object
Returns the value of attribute title
5 6 7 |
# File 'lib/ex_ua/item.rb', line 5 def title @title end |
Class Method Details
.parse_links(links) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ex_ua/item.rb', line 6 def self.parse_links(links) self.new.tap do |item| links.each { |link| case link.attributes["href"].value when %r{^/get/} item.title = link.attributes["title"].value item.id = link.attributes["href"].value.match(%r{^/get/(\d+)})[1].to_i when %r{^/load} item.additional_servers||=[] item.additional_servers << link.attributes["title"].value.match(%r{fs(\d+)})[1].to_i end } end end |
Instance Method Details
#download_uri ⇒ Object
38 39 40 |
# File 'lib/ex_ua/item.rb', line 38 def download_uri @downoadload_url ||= Addressable::URI.join(ExUA::BASE_URL, "/load/#{self.id}") end |
#get_uri ⇒ Object
Actual download url with ex.ua included You can add ?fs_id=server_id param to download form #additional_servers @return
34 35 36 |
# File 'lib/ex_ua/item.rb', line 34 def get_uri @get_url ||= Addressable::URI.join(ExUA::BASE_URL,"/get/#{self.id}") end |
#retrieve_real_get_url ⇒ Object
26 27 28 |
# File 'lib/ex_ua/item.rb', line 26 def retrieve_real_get_url retrieve_real_url(get_uri) end |
#retrieve_real_load_url ⇒ Object
Queries ex.ua to get a real url to fetch data from (follows redirect)
22 23 24 |
# File 'lib/ex_ua/item.rb', line 22 def retrieve_real_load_url retrieve_real_url(download_uri) end |