Class: TorrentCrawler::Torrent

Inherits:
Object
  • Object
show all
Defined in:
lib/torrent_crawler/torrent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filesObject

Returns the value of attribute files


47
48
49
# File 'lib/torrent_crawler/torrent.rb', line 47

def files
  @files
end

#hashObject

Returns the value of attribute hash


15
16
17
# File 'lib/torrent_crawler/torrent.rb', line 15

def hash
  @hash
end

#leechersObject

Returns the value of attribute leechers


51
52
53
# File 'lib/torrent_crawler/torrent.rb', line 51

def leechers
  @leechers
end

#seedersObject

Returns the value of attribute seeders


49
50
51
# File 'lib/torrent_crawler/torrent.rb', line 49

def seeders
  @seeders
end

#snatchesObject

Returns the value of attribute snatches


53
54
55
# File 'lib/torrent_crawler/torrent.rb', line 53

def snatches
  @snatches
end

#titleObject

Returns the value of attribute title


17
18
19
# File 'lib/torrent_crawler/torrent.rb', line 17

def title
  @title
end

#tracker_idObject

Returns the value of attribute tracker_id


5
6
7
# File 'lib/torrent_crawler/torrent.rb', line 5

def tracker_id
  @tracker_id
end

#tracker_keyObject

Returns the value of attribute tracker_key


3
4
5
# File 'lib/torrent_crawler/torrent.rb', line 3

def tracker_key
  @tracker_key
end

#uploaded_atObject

Returns the value of attribute uploaded_at


55
56
57
# File 'lib/torrent_crawler/torrent.rb', line 55

def uploaded_at
  @uploaded_at
end

#uploaderObject

Returns the value of attribute uploader


19
20
21
# File 'lib/torrent_crawler/torrent.rb', line 19

def uploader
  @uploader
end

Instance Method Details

#idObject


7
8
9
# File 'lib/torrent_crawler/torrent.rb', line 7

def id
  tracker_id
end

#id=(value) ⇒ Object


11
12
13
# File 'lib/torrent_crawler/torrent.rb', line 11

def id=(value)
  tracker_id = value
end

#sizeObject


21
22
23
# File 'lib/torrent_crawler/torrent.rb', line 21

def size
  @size ||= 0
end

#size=(value) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/torrent_crawler/torrent.rb', line 25

def size=(value)
  if value.respond_to? :downcase
    if value =~ /^([0-9\.]+)(.*)$/
      value = $1.strip.to_f
      unit  = $2.strip.gsub(/[^A-Za-z]/, '')

      case unit
      when /tb/i
        value *= 1024 * 1024 * 1024
      when /gb/i
        value *= 1024 * 1024
      when /mb/i, /megabytes?/i
        value *= 1024
      end

      @size = value.to_i
    end
  else
    @size = value.to_i
  end
end

#tagsObject


57
58
59
# File 'lib/torrent_crawler/torrent.rb', line 57

def tags
  @tags ||= []
end