class CampfireChat::Client
Attributes
config[R]
last_message_id[RW]
Public Class Methods
new(config = CampfireChat.config)
click to toggle source
# File lib/campfire_chat/client.rb, line 6 def initialize(config = CampfireChat.config) @config = config end
Public Instance Methods
messages()
click to toggle source
# File lib/campfire_chat/client.rb, line 14 def messages recent_messages = room.recent.select {|x| x.type == 'TextMessage' } recent_messages = recent_messages.select {|x| x.id.to_i > last_message_id.to_i }.map {|m| build_message(m) } self.last_message_id = recent_messages.last.id unless recent_messages.empty? recent_messages end
tinder()
click to toggle source
# File lib/campfire_chat/client.rb, line 10 def tinder @tinder ||= Tinder::Campfire.new(config.subdomain, :token => config.token) end
Private Instance Methods
build_message(msg)
click to toggle source
# File lib/campfire_chat/client.rb, line 23 def build_message(msg) CampfireChat::Message.new(msg) end
room()
click to toggle source
# File lib/campfire_chat/client.rb, line 27 def room @room ||= tinder.find_room_by_name(config.room) end