Class: Scamp
- Inherits:
-
Object
- Object
- Scamp
- Includes:
- Connection, Messages, Rooms, Users
- Defined in:
- lib/scamp/action.rb,
lib/scamp.rb,
lib/scamp/rooms.rb,
lib/scamp/users.rb,
lib/scamp/matcher.rb,
lib/scamp/version.rb,
lib/scamp/messages.rb,
lib/scamp/connection.rb
Overview
:created_at=>“2011/09/10 00:23:19 +0000”, :body=>“something”, :id=>408089344, :user_id=>774016, :type=>“TextMessage”
Defined Under Namespace
Modules: Connection, Messages, Rooms, Users Classes: Action, Matcher
Constant Summary collapse
- VERSION =
"0.2.1"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#first_match_only ⇒ Object
Returns the value of attribute first_match_only.
-
#ignore_self ⇒ Object
Returns the value of attribute ignore_self.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#matchers ⇒ Object
Returns the value of attribute matchers.
-
#required_prefix ⇒ Object
Returns the value of attribute required_prefix.
-
#room_cache ⇒ Object
Returns the value of attribute room_cache.
-
#rooms ⇒ Object
Returns the value of attribute rooms.
-
#rooms_to_join ⇒ Object
Returns the value of attribute rooms_to_join.
-
#subdomain ⇒ Object
Returns the value of attribute subdomain.
-
#user_cache ⇒ Object
Returns the value of attribute user_cache.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #behaviour(&block) ⇒ Object
- #command_list ⇒ Object
- #connect!(room_list) ⇒ Object
-
#initialize(options = {}) ⇒ Scamp
constructor
A new instance of Scamp.
Methods included from Messages
Methods included from Users
Methods included from Rooms
#join, #room_id, #room_name_for, #upload
Constructor Details
#initialize(options = {}) ⇒ Scamp
Returns a new instance of Scamp.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/scamp.rb', line 24 def initialize( = {}) ||= {} raise ArgumentError, "You must pass an API key" unless [:api_key] raise ArgumentError, "You must pass a subdomain" unless [:subdomain] .each do |k,v| s = "#{k}=" if respond_to?(s) send(s, v) else logger.warn "Scamp initialized with #{k.inspect} => #{v.inspect} but NO UNDERSTAND!" end end @rooms_to_join = [] @rooms = {} @user_cache = {} @room_cache = {} @matchers ||= [] end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
20 21 22 |
# File 'lib/scamp.rb', line 20 def api_key @api_key end |
#first_match_only ⇒ Object
Returns the value of attribute first_match_only.
20 21 22 |
# File 'lib/scamp.rb', line 20 def first_match_only @first_match_only end |
#ignore_self ⇒ Object
Returns the value of attribute ignore_self.
20 21 22 |
# File 'lib/scamp.rb', line 20 def ignore_self @ignore_self end |
#logger ⇒ Object
Returns the value of attribute logger.
20 21 22 |
# File 'lib/scamp.rb', line 20 def logger @logger end |
#matchers ⇒ Object
Returns the value of attribute matchers.
20 21 22 |
# File 'lib/scamp.rb', line 20 def matchers @matchers end |
#required_prefix ⇒ Object
Returns the value of attribute required_prefix.
20 21 22 |
# File 'lib/scamp.rb', line 20 def required_prefix @required_prefix end |
#room_cache ⇒ Object
Returns the value of attribute room_cache.
20 21 22 |
# File 'lib/scamp.rb', line 20 def room_cache @room_cache end |
#rooms ⇒ Object
Returns the value of attribute rooms.
20 21 22 |
# File 'lib/scamp.rb', line 20 def rooms @rooms end |
#rooms_to_join ⇒ Object
Returns the value of attribute rooms_to_join.
20 21 22 |
# File 'lib/scamp.rb', line 20 def rooms_to_join @rooms_to_join end |
#subdomain ⇒ Object
Returns the value of attribute subdomain.
20 21 22 |
# File 'lib/scamp.rb', line 20 def subdomain @subdomain end |
#user_cache ⇒ Object
Returns the value of attribute user_cache.
20 21 22 |
# File 'lib/scamp.rb', line 20 def user_cache @user_cache end |
#verbose ⇒ Object
Returns the value of attribute verbose.
20 21 22 |
# File 'lib/scamp.rb', line 20 def verbose @verbose end |
Instance Method Details
#behaviour(&block) ⇒ Object
45 46 47 |
# File 'lib/scamp.rb', line 45 def behaviour &block instance_eval &block end |
#command_list ⇒ Object
54 55 56 |
# File 'lib/scamp.rb', line 54 def command_list matchers.map{|m| [m.trigger, m.conditions] } end |
#connect!(room_list) ⇒ Object
49 50 51 52 |
# File 'lib/scamp.rb', line 49 def connect!(room_list) logger.info "Starting up" connect(api_key, room_list) end |