Class: ExtratorrentSearch::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/extratorrent_search/link.rb

Overview

Object that contains the info for a torrent file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename: nil, size: nil, magnet_link: nil, seeders: nil, leechers: nil) ⇒ Link

Returns a new instance of Link.



10
11
12
13
14
15
16
# File 'lib/extratorrent_search/link.rb', line 10

def initialize(filename: nil, size: nil, magnet_link: nil, seeders: nil, leechers: nil)
  @filename = filename
  @size = size
  @magnet_link = magnet_link
  @seeders = seeders
  @leechers = leechers
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/extratorrent_search/link.rb', line 8

def filename
  @filename
end

#leechersObject (readonly)

Returns the value of attribute leechers.



8
9
10
# File 'lib/extratorrent_search/link.rb', line 8

def leechers
  @leechers
end

Returns the value of attribute magnet_link.



8
9
10
# File 'lib/extratorrent_search/link.rb', line 8

def magnet_link
  @magnet_link
end

#seedersObject (readonly)

Returns the value of attribute seeders.



8
9
10
# File 'lib/extratorrent_search/link.rb', line 8

def seeders
  @seeders
end

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'lib/extratorrent_search/link.rb', line 8

def size
  @size
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
# File 'lib/extratorrent_search/link.rb', line 18

def <=>(other)
  @seeders <=> other.seeders
end

#info_hashObject



26
27
28
# File 'lib/extratorrent_search/link.rb', line 26

def info_hash
  @info_hash ||= extract_hash
end

#to_sObject



22
23
24
# File 'lib/extratorrent_search/link.rb', line 22

def to_s
  "#{@filename} (#{@size}) - [#{@seeders.green}/#{@leechers.red}]"
end