Class: EventMachine::Campfire

Inherits:
Object
  • Object
show all
Includes:
Connection, Messages, Rooms, Users
Defined in:
lib/em-campfire.rb,
lib/em-campfire/cache.rb,
lib/em-campfire/rooms.rb,
lib/em-campfire/users.rb,
lib/em-campfire/version.rb,
lib/em-campfire/messages.rb,
lib/em-campfire/connection.rb

Defined Under Namespace

Modules: Connection, Messages, Rooms, Users Classes: Cache

Constant Summary collapse

VERSION =
"1.1.2"

Instance Attribute Summary collapse

Attributes included from Rooms

#room_cache

Attributes included from Connection

#ignore_self

Instance Method Summary collapse

Methods included from Messages

#paste, #play, #say

Methods included from Users

#fetch_user_data_for_self, #fetch_user_data_for_user_id, #is_me?

Methods included from Rooms

#join, #room_data_for_all_rooms, #room_data_from_room_id, #stream

Methods included from Connection

#on_message

Constructor Details

#initialize(options = {}) ⇒ Campfire

Returns a new instance of Campfire.

Raises:

  • (ArgumentError)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/em-campfire.rb', line 22

def initialize(options = {})
  raise ArgumentError, "You must pass an API key" unless options[:api_key]
  raise ArgumentError, "You must pass a subdomain" unless options[:subdomain]

  options.each do |k,v|
    s = "#{k}="
    if respond_to?(s)
      send(s, v)
    else
      raise ArgumentError, "#{k.inspect} is not a valid option"
    end
  end

  fetch_user_data_for_self
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



15
16
17
# File 'lib/em-campfire.rb', line 15

def api_key
  @api_key
end

#ignore_timestampsObject

Returns the value of attribute ignore_timestamps.



15
16
17
# File 'lib/em-campfire.rb', line 15

def ignore_timestamps
  @ignore_timestamps
end

#loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/em-campfire.rb', line 15

def logger
  @logger
end

#subdomainObject

Returns the value of attribute subdomain.



15
16
17
# File 'lib/em-campfire.rb', line 15

def subdomain
  @subdomain
end

#verboseObject

Returns the value of attribute verbose.



15
16
17
# File 'lib/em-campfire.rb', line 15

def verbose
  @verbose
end

Instance Method Details

#cacheObject



43
44
45
# File 'lib/em-campfire.rb', line 43

def cache
  @cache ||= EventMachine::Campfire::Cache.new
end

#cache=(a_cache) ⇒ Object

Raises:

  • (ArgumentError)


38
39
40
41
# File 'lib/em-campfire.rb', line 38

def cache=(a_cache)
  raise(ArgumentError, "You must pass a conforming cache object") unless a_cache.respond_to(:set) && a_cache.respond_to(:get)
  @cache = a_cache
end

#ignore_timestamps?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/em-campfire.rb', line 60

def ignore_timestamps?
  self.ignore_timestamps || false
end