Class: Blabber::Campfire

Inherits:
Object
  • Object
show all
Includes:
Channel
Defined in:
lib/blabber/campfire.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Campfire

Returns a new instance of Campfire.



12
13
14
15
16
17
18
19
20
# File 'lib/blabber/campfire.rb', line 12

def initialize(opts)
  @opts = opts
  Broach.settings = @opts.keys.inject({'use_ssl' => true}) do |acc, key|
    if(['account', 'token'].include?(key))
      acc[key] = @opts[key]
    end 
    acc
  end
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



8
9
10
# File 'lib/blabber/campfire.rb', line 8

def opts
  @opts
end

Instance Method Details

#loglevelsObject



22
23
24
# File 'lib/blabber/campfire.rb', line 22

def loglevels
  @opts['loglevels']
end

#speak(message, loglevel, opts) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/blabber/campfire.rb', line 26

def speak(message, loglevel, opts)
  msg_opts = {}
  if message.gsub(/\n|\r/, "") != message
    msg_opts[:type] = :paste
  end
  Broach.speak(@opts['room'], message, msg_opts)
end