Class: Moneypenny::Connections::Campfire
- Inherits:
-
Object
- Object
- Moneypenny::Connections::Campfire
- Defined in:
- lib/moneypenny/connections/campfire.rb
Instance Method Summary collapse
-
#initialize(subdomain, room_name, api_token) ⇒ Campfire
constructor
A new instance of Campfire.
- #listen(&block) ⇒ Object
- #reconnect ⇒ Object
- #room ⇒ Object
- #say(message) ⇒ Object
Constructor Details
#initialize(subdomain, room_name, api_token) ⇒ Campfire
Returns a new instance of Campfire.
6 7 8 9 10 |
# File 'lib/moneypenny/connections/campfire.rb', line 6 def initialize(subdomain, room_name, api_token) @subdomain = subdomain @room_name = room_name @api_token = api_token end |
Instance Method Details
#listen(&block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/moneypenny/connections/campfire.rb', line 35 def listen(&block) begin room.listen do || begin block.call(['body']) if ['user']['id'] != @id rescue Exception => exception puts exception.to_s end end rescue Tinder::ListenFailed reconnect retry end end |
#reconnect ⇒ Object
22 23 24 25 |
# File 'lib/moneypenny/connections/campfire.rb', line 22 def reconnect @room = nil room end |
#room ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/moneypenny/connections/campfire.rb', line 12 def room unless @room campfire = Tinder::Campfire.new @subdomain, :token => @api_token @id = campfire.me['id'] @room = campfire.find_room_by_name @room_name raise 'Unknown Room' unless @room end @room end |
#say(message) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/moneypenny/connections/campfire.rb', line 27 def say() if .include?("\n") room.paste else room.speak end end |