Class: Demonoid::Result
- Inherits:
-
Object
- Object
- Demonoid::Result
- Defined in:
- lib/demonoid/result.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#date_created ⇒ Object
Returns the value of attribute date_created.
-
#detail_link ⇒ Object
Returns the value of attribute detail_link.
-
#leeches ⇒ Object
Returns the value of attribute leeches.
-
#link ⇒ Object
Returns the value of attribute link.
-
#magnet_link ⇒ Object
Returns the value of attribute magnet_link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#seeds ⇒ Object
Returns the value of attribute seeds.
-
#size ⇒ Object
Returns the value of attribute size.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(row = []) ⇒ Result
constructor
A new instance of Result.
- #to_s ⇒ Object
Constructor Details
#initialize(row = []) ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/demonoid/result.rb', line 5 def initialize(row = []) self.name = row[0].search('td')[1].search('a').inner_html self.detail_link = row[0].search('td')[1].search('a').first.get_attribute('href') base_url = "http://www.demonoid.me" self.link = base_url + row[1].search('td')[2].search('a').first.get_attribute('href') self.magnet_link = base_url + row[1].search('td')[2].search('a')[1].get_attribute('href') self.seeds = row[1].search('td')[6].search('font').inner_html.to_i self.leeches = row[1].search('td')[7].search('font').inner_html.to_i raw_filesize = row[1].search('td')[3].inner_html self.size = Demonoid::Result.filesize_in_bytes(raw_filesize) end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def category @category end |
#date_created ⇒ Object
Returns the value of attribute date_created.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def date_created @date_created end |
#detail_link ⇒ Object
Returns the value of attribute detail_link.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def detail_link @detail_link end |
#leeches ⇒ Object
Returns the value of attribute leeches.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def leeches @leeches end |
#link ⇒ Object
Returns the value of attribute link.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def link @link end |
#magnet_link ⇒ Object
Returns the value of attribute magnet_link.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def magnet_link @magnet_link end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def name @name end |
#seeds ⇒ Object
Returns the value of attribute seeds.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def seeds @seeds end |
#size ⇒ Object
Returns the value of attribute size.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def size @size end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/demonoid/result.rb', line 3 def status @status end |
Class Method Details
.filesize_in_bytes(filesize) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/demonoid/result.rb', line 22 def self.filesize_in_bytes(filesize) match = filesize.match(/([\d\.]+) (.*)/) if match raw_size = match[1].to_f case match[2].strip when /gb/i then raw_size * 1000000000 when /mb/i then raw_size * 1000000 when /kb/i then raw_size * 1000 else nil end else nil end end |
Instance Method Details
#to_s ⇒ Object
18 19 20 |
# File 'lib/demonoid/result.rb', line 18 def to_s "<Demonoid::Result @name => #{name}, @seeds => #{seeds}, @size => #{size}>" end |