Class: HWPing::Config
- Inherits:
-
Object
- Object
- HWPing::Config
- Defined in:
- lib/hwping/config.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#nick ⇒ Object
readonly
Returns the value of attribute nick.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#targets ⇒ Object
Returns the value of attribute targets.
-
#webcam ⇒ Object
readonly
Returns the value of attribute webcam.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
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
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
3 4 5 |
# File 'lib/hwping/config.rb', line 3 def auth @auth end |
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
4 5 6 |
# File 'lib/hwping/config.rb', line 4 def channels @channels end |
#nick ⇒ Object (readonly)
Returns the value of attribute nick.
5 6 7 |
# File 'lib/hwping/config.rb', line 5 def nick @nick end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/hwping/config.rb', line 6 def port @port end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
7 8 9 |
# File 'lib/hwping/config.rb', line 7 def server @server end |
#targets ⇒ Object
Returns the value of attribute targets.
9 10 11 |
# File 'lib/hwping/config.rb', line 9 def targets @targets end |
#webcam ⇒ Object (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_hash ⇒ Object
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 |