Class: Configuration

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/transmission-connect/configuration.rb

Defined Under Namespace

Classes: Client

Instance Method Summary collapse

Constructor Details

#initialize(args = []) ⇒ Configuration

def initialize(args) args - array of hashes:

args = [
    {
        :host => '127.0.0.1',
        :port => 9091,
        :down => true
    },
    {
        :host => '127.0.0.1',
        :port => 9092,
        :up => true
    },
    {
        :host => '192.168.100.199',
        :port => 9091,
        :username => 'username',
        :password => 'password',
        :down => true,
        :up => true
    }
]


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/transmission-connect/configuration.rb', line 26

def initialize(args = [])
  @clients = []
  @downs = []
  @ups = []
  args.each do |arg|
    client = Client.new(arg)
    @clients << client
    @downs << client if arg.key?(:down) && arg[:down]
    @ups << client if arg.key?(:up) && arg[:up]
  end
end

Instance Method Details

#eachObject



38
39
40
# File 'lib/transmission-connect/configuration.rb', line 38

def each
  @clients.each{|i| yield i}
end

#each_downsObject



46
47
48
# File 'lib/transmission-connect/configuration.rb', line 46

def each_downs
  @downs.each{|i| yield i}
end

#each_upsObject



42
43
44
# File 'lib/transmission-connect/configuration.rb', line 42

def each_ups
  @ups.each{|i| yield i}
end