Class: Matchstick::Room

Inherits:
Campfire show all
Defined in:
lib/matchstick/room.rb

Constant Summary

Constants inherited from Campfire

Campfire::HOST

Instance Attribute Summary collapse

Attributes inherited from Campfire

#api_key, #subdomain, #use_ssl

Instance Method Summary collapse

Methods inherited from Campfire

#get, #post, #rooms

Constructor Details

#initialize(raw_room, connection) ⇒ Room

Returns a new instance of Room.



7
8
9
10
11
# File 'lib/matchstick/room.rb', line 7

def initialize(raw_room, connection)
  @name       = raw_room["name"]
  @id         = raw_room["id"]
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/matchstick/room.rb', line 5

def connection
  @connection
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/matchstick/room.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/matchstick/room.rb', line 5

def name
  @name
end

Instance Method Details

#joinObject



25
26
27
# File 'lib/matchstick/room.rb', line 25

def join
  post("room/#{@id}/join")
end

#leaveObject



29
30
31
# File 'lib/matchstick/room.rb', line 29

def leave
  post("room/#{@id}/leave")
end

#paste(message) ⇒ Object



19
20
21
22
23
# File 'lib/matchstick/room.rb', line 19

def paste(message)
  post("room/#{@id}/speak", {:message =>
    {:type => "PasteMessage", :body => message}
  })
end

#speak(message) ⇒ Object



13
14
15
16
17
# File 'lib/matchstick/room.rb', line 13

def speak(message)
  post("room/#{@id}/speak", {:message =>
    {:type => "TextMessage", :body => message}
  })
end