class Rootor

Attributes

client[RW]
torrents[RW]

Public Class Methods

new(xmlrpc_url) click to toggle source
# File lib/rootor.rb, line 11
def initialize(xmlrpc_url)
  @client = Client.new2(xmlrpc_url)
  @torrents = refresh!
end

Public Instance Methods

find(str) click to toggle source
# File lib/rootor.rb, line 28
def find(str)
  return [] if str.empty? || !str.instance_of?(String)
  @torrents.map do |t|
    t if t.serialize.values.any? { |tt| tt.downcase.include? str.downcase } rescue nil
  end.compact
end
json_torrents() click to toggle source
# File lib/rootor.rb, line 24
def json_torrents
  serialized_torrents.to_json
end
load_from_file(path) click to toggle source
# File lib/rootor.rb, line 43
def load_from_file(path)
  load_from_raw(File.read(path))
end
load_from_raw(data) click to toggle source
# File lib/rootor.rb, line 35
def load_from_raw(data)
  @client.load_start(XMLRPC::Base64.new(data))
end
refresh!() click to toggle source
# File lib/rootor.rb, line 16
def refresh!
  @torrents = @client.fetch
end
remove(hash) click to toggle source
# File lib/rootor.rb, line 39
def remove(hash)
  @client.erase(hash)
end
serialized_torrents() click to toggle source
# File lib/rootor.rb, line 20
def serialized_torrents
  @torrents.map(&:serialize)
end