Class: CampfireChat::Configuration
- Inherits:
-
Object
- Object
- CampfireChat::Configuration
- Defined in:
- lib/campfire_chat/configuration.rb
Instance Attribute Summary collapse
-
#pairs ⇒ Object
readonly
Returns the value of attribute pairs.
-
#room ⇒ Object
readonly
Returns the value of attribute room.
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #add_pair(name) ⇒ Object
-
#initialize(attrs = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(attrs = {}) ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 |
# File 'lib/campfire_chat/configuration.rb', line 18 def initialize(attrs={}) @token = attrs[:token] @subdomain = attrs[:subdomain] @room = attrs[:room] @pairs = [] end |
Instance Attribute Details
#pairs ⇒ Object (readonly)
Returns the value of attribute pairs.
4 5 6 |
# File 'lib/campfire_chat/configuration.rb', line 4 def pairs @pairs end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
4 5 6 |
# File 'lib/campfire_chat/configuration.rb', line 4 def room @room end |
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
4 5 6 |
# File 'lib/campfire_chat/configuration.rb', line 4 def subdomain @subdomain end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
4 5 6 |
# File 'lib/campfire_chat/configuration.rb', line 4 def token @token end |
Class Method Details
.build(path = nil) ⇒ Object
6 7 8 9 |
# File 'lib/campfire_chat/configuration.rb', line 6 def self.build(path = nil) path ||= Pathname.new(ENV['HOME']).join('.campfire.yml') new load_config(path) end |
.load_config(path) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/campfire_chat/configuration.rb', line 11 def self.load_config(path) conf = YAML.load_file(path) || {} Hash[conf.map{ |k, v| [k.to_sym, v] }] rescue Errno::ENOENT, TypeError {} end |
Instance Method Details
#add_pair(name) ⇒ Object
25 26 27 |
# File 'lib/campfire_chat/configuration.rb', line 25 def add_pair(name) pairs << CampfireChat::Engineer.new(:name => name) end |