Class: RUTorrent::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/rutorrent/settings.rb

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Settings

Returns a new instance of Settings.



3
4
5
6
7
# File 'lib/rutorrent/settings.rb', line 3

def initialize(server)
  @server = server
  @settings = nil
  @dirty = false
end

Instance Method Details

#[](key) ⇒ Object



15
16
17
18
# File 'lib/rutorrent/settings.rb', line 15

def [](key)
  reload_if_necessary
  @settings[key]
end

#[]=(key, value) ⇒ Object



20
21
22
23
# File 'lib/rutorrent/settings.rb', line 20

def []=(key, value)
  @server.request(:action => 'setsetting', :s => key, :v => value)
  @dirty = true
end

#reloadObject



9
10
11
12
13
# File 'lib/rutorrent/settings.rb', line 9

def reload
  json = @server.request(:action => 'getsettings')
  @settings = Hash[json['settings'].map{|s| [s[0], s[2]] }]
  @dirty = false
end

#to_hashObject



25
26
27
28
# File 'lib/rutorrent/settings.rb', line 25

def to_hash
  reload_if_necessary
  @settings.dup
end