Class: Jabbot::Config
- Inherits:
-
Struct
- Object
- Struct
- Jabbot::Config
- Defined in:
- lib/jabbot/config.rb
Overview
The main configuration of Jabbot. It’s nothing more than a simple struct of key-value pairs.
Examples:
Jabbot::Config.new({:login => "[email protected]", :password => "secret",
:debug => true})
# => #<struct Jabbot::Config login="[email protected]", password="secret",
nick="jabbot", server=nil, channel=nil, resource="jabbot",
log_level="info", log_file=nil, debug=true>
Jabbot::Config.new("[email protected]", "secret")
# => #<struct Jabbot::Config login="[email protected]", password="secret",
nick="jabbot", server=nil, channel=nil, resource="jabbot",
log_level="info", log_file=nil, debug=false>
config.login
# => "[email protected]"
config.channel
# => nil
config.channel = "[email protected]"
# => "[email protected]"
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#channel_password ⇒ Object
Returns the value of attribute channel_password.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#login ⇒ Object
Returns the value of attribute login.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#password ⇒ Object
Returns the value of attribute password.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Config
constructor
Public: Initialize new configuration object.
Constructor Details
#initialize(*args) ⇒ Config
Public: Initialize new configuration object.
*args - Any number of valid arguments passed to the super class.
If there is only one argument and it is kind of a Hash,
it is treated as the key-value pairs are the options.
If there is a default value for an option key,
it is set if needed.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/jabbot/config.rb', line 61 def initialize(*args) # First: call the super class. super # If we got a hash, treat it as the configuration options. if args.size == 1 && args.first.kind_of?(Hash) self.login = nil # Reset first value. args.first.each do |key, value| send("#{key}=", value) end end # Set defaults. DEFAULT_CONFIG.each do |key, value| self.send(key.to_s) || self.send("#{key}=", value) end end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def channel @channel end |
#channel_password ⇒ Object
Returns the value of attribute channel_password
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def channel_password @channel_password end |
#debug ⇒ Object
Returns the value of attribute debug
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def debug @debug end |
#log_file ⇒ Object
Returns the value of attribute log_file
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def log_file @log_file end |
#log_level ⇒ Object
Returns the value of attribute log_level
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def log_level @log_level end |
#login ⇒ Object
Returns the value of attribute login
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def login @login end |
#nick ⇒ Object
Returns the value of attribute nick
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def nick @nick end |
#password ⇒ Object
Returns the value of attribute password
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def password @password end |
#resource ⇒ Object
Returns the value of attribute resource
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def resource @resource end |
#server ⇒ Object
Returns the value of attribute server
41 42 43 |
# File 'lib/jabbot/config.rb', line 41 def server @server end |