Class: TorrentRSS::EntryLog
- Inherits:
-
Object
- Object
- TorrentRSS::EntryLog
- Defined in:
- lib/torrent_rss/entry_log.rb
Class Method Summary collapse
- .add(entry_id) ⇒ Object
- .encode_entry(entry_id) ⇒ Object
- .entries ⇒ Object
- .file_path ⇒ Object
- .has?(entry_id) ⇒ Boolean
- .read ⇒ Object
- .save ⇒ Object
Class Method Details
.add(entry_id) ⇒ Object
26 27 28 29 |
# File 'lib/torrent_rss/entry_log.rb', line 26 def add entry_id entries << encode_entry(entry_id) save end |
.encode_entry(entry_id) ⇒ Object
22 23 24 |
# File 'lib/torrent_rss/entry_log.rb', line 22 def encode_entry entry_id Digest::MD5.hexdigest entry_id end |
.entries ⇒ Object
10 11 12 |
# File 'lib/torrent_rss/entry_log.rb', line 10 def entries @entries ||= read end |
.file_path ⇒ Object
35 36 37 |
# File 'lib/torrent_rss/entry_log.rb', line 35 def file_path File.("~/.torrent_rss_log") end |
.has?(entry_id) ⇒ Boolean
6 7 8 |
# File 'lib/torrent_rss/entry_log.rb', line 6 def has? entry_id entries.include? encode_entry(entry_id) end |
.read ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/torrent_rss/entry_log.rb', line 14 def read if File.exists? file_path File.read(file_path).split("\n") else [] end end |
.save ⇒ Object
31 32 33 |
# File 'lib/torrent_rss/entry_log.rb', line 31 def save File.write file_path, entries.join("\n") end |