Class: CeilingCat::Setup
- Inherits:
-
Object
- Object
- CeilingCat::Setup
- Defined in:
- lib/ceiling_cat/setup.rb
Class Attribute Summary collapse
-
.config ⇒ Object
Class-level config.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Configures the connection at the class level.
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(_config = nil) ⇒ Setup
constructor
A new instance of Setup.
Constructor Details
#initialize(_config = nil) ⇒ Setup
Returns a new instance of Setup.
31 32 33 |
# File 'lib/ceiling_cat/setup.rb', line 31 def initialize(_config = nil) self.config = _config || self.class.config end |
Class Attribute Details
.config ⇒ Object
Class-level config. This is set by the configure
class method, and is used if no configuration is passed to the initialize
method.
12 13 14 |
# File 'lib/ceiling_cat/setup.rb', line 12 def config @config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/ceiling_cat/setup.rb', line 6 def config @config end |
Class Method Details
.configure {|config| ... } ⇒ Object
Configures the connection at the class level. When the ceiling_cat
bin file is loaded, it evals the file referenced by the first command-line parameter. This file can configure the connection instance later created by robut
by setting parameters in the CeilingCat::Connection.configure block.
20 21 22 23 |
# File 'lib/ceiling_cat/setup.rb', line 20 def self.configure self.config = OpenStruct.new yield config end |
Instance Method Details
#connect ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ceiling_cat/setup.rb', line 35 def connect case self.config.service.downcase when 'campfire' connection = CeilingCat::Campfire::Connection.new(self.config) room = CeilingCat::Campfire::Room.new(:connection => connection, :room_name => self.config.room) room.watch when 'irc' connection = CeilingCat::IRC::Connection.new(self.config) room = CeilingCat::IRC::Room.new(:connection => connection, :room_name => self.config.room) room.watch else raise CeilingCat::UnsupportedChatServiceError.new("#{self.config.service} is not a supported chat service.") end end |