Class: HWPing::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/hwping/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
# File 'lib/hwping/config.rb', line 11

def initialize(hash = {})
  @server   = hash.fetch('server',   'irc.freenode.net')
  @port     = hash.fetch('port',     6667)
  @nick     = hash.fetch('nick',     'hwping')
  @channels = hash.fetch('channels', ['hwping-test'])
  @auth     = hash.fetch('auth'    , [])
  @targets  = hash.fetch('targets',  [])
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



8
9
10
# File 'lib/hwping/config.rb', line 8

def auth
  @auth
end

#channelsObject (readonly)

Returns the value of attribute channels.



7
8
9
# File 'lib/hwping/config.rb', line 7

def channels
  @channels
end

#nickObject (readonly)

Returns the value of attribute nick.



6
7
8
# File 'lib/hwping/config.rb', line 6

def nick
  @nick
end

#portObject (readonly)

Returns the value of attribute port.



5
6
7
# File 'lib/hwping/config.rb', line 5

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



4
5
6
# File 'lib/hwping/config.rb', line 4

def server
  @server
end

#targetsObject

Returns the value of attribute targets.



9
10
11
# File 'lib/hwping/config.rb', line 9

def targets
  @targets
end

Instance Method Details

#to_hashObject



20
21
22
# File 'lib/hwping/config.rb', line 20

def to_hash
  Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }]
end