class ExtratorrentSearch::Link
Object that contains the info for a torrent file
Attributes
filename[R]
leechers[R]
magnet_link[R]
seeders[R]
size[R]
Public Class Methods
new(filename: nil, size: nil, magnet_link: nil, seeders: nil, leechers: nil)
click to toggle source
# 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
Public Instance Methods
<=>(other)
click to toggle source
# File lib/extratorrent_search/link.rb, line 18 def <=>(other) @seeders <=> other.seeders end
info_hash()
click to toggle source
# File lib/extratorrent_search/link.rb, line 26 def info_hash @info_hash ||= extract_hash end
to_s()
click to toggle source
# File lib/extratorrent_search/link.rb, line 22 def to_s "#{@filename} (#{@size}) - [#{@seeders.green}/#{@leechers.red}]" end
Private Instance Methods
extract_hash()
click to toggle source
# File lib/extratorrent_search/link.rb, line 32 def extract_hash # Extract magnet properties to a Hash and then parse the sha1 info hash raw_hash = magnet_link[/(xt.*?)&/, 1] # extract the xt property raw_hash.split(':').last.downcase end