Class: CampfireChat::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/campfire_chat/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = CampfireChat.config) ⇒ Client

Returns a new instance of Client.



6
7
8
# File 'lib/campfire_chat/client.rb', line 6

def initialize(config = CampfireChat.config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



4
5
6
# File 'lib/campfire_chat/client.rb', line 4

def config
  @config
end

#last_message_idObject

Returns the value of attribute last_message_id.



5
6
7
# File 'lib/campfire_chat/client.rb', line 5

def last_message_id
  @last_message_id
end

Instance Method Details

#messagesObject



14
15
16
17
18
19
# 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

#tinderObject



10
11
12
# File 'lib/campfire_chat/client.rb', line 10

def tinder
  @tinder ||= Tinder::Campfire.new(config.subdomain, :token => config.token)
end