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
19
# 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 = Array(hash.fetch('channels', ['hwping-test']))
  @auth     = Array(hash.fetch('auth', []))
  @targets  = hash.fetch('targets', {}).to_h
  @webcam   = hash.fetch('webcam', {}).to_h
end

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



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

def auth
  @auth
end

#channelsObject (readonly)

Returns the value of attribute channels.



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

def channels
  @channels
end

#nickObject (readonly)

Returns the value of attribute nick.



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

def nick
  @nick
end

#portObject (readonly)

Returns the value of attribute port.



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

def port
  @port
end

#serverObject (readonly)

Returns the value of attribute server.



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

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

#webcamObject (readonly)

Returns the value of attribute webcam.



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

def webcam
  @webcam
end

Instance Method Details

#to_hashObject



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

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