Class: MicroFire
- Inherits:
-
Object
- Object
- MicroFire
- Defined in:
- lib/micro_fire.rb
Constant Summary collapse
- VERSION =
'1.0.1'
Class Attribute Summary collapse
-
.json ⇒ Object
Returns the value of attribute json.
-
.stream ⇒ Object
Returns the value of attribute stream.
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#json ⇒ Object
Returns the value of attribute json.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#room ⇒ Object
readonly
Returns the value of attribute room.
-
#stream ⇒ Object
Returns the value of attribute stream.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(uri, token, room) ⇒ MicroFire
constructor
A new instance of MicroFire.
- #join(&block) ⇒ Object
- #speak(message, &block) ⇒ Object
- #watch(&block) ⇒ Object
Constructor Details
#initialize(uri, token, room) ⇒ MicroFire
Returns a new instance of MicroFire.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/micro_fire.rb', line 30 def initialize uri, token, room @stream = self.class.stream @json = self.class.json @token = token @http = Net::HTTP::Persistent.new # Don't do anything if not supported by net/http/persistent version or # socket.so. Helps when they deploy. if @http.respond_to? :socket_options @http. << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1] end @pass = 'x' @uri = find_uri uri @room = find_room room end |
Class Attribute Details
.json ⇒ Object
Returns the value of attribute json.
12 13 14 |
# File 'lib/micro_fire.rb', line 12 def json @json end |
.stream ⇒ Object
Returns the value of attribute stream.
12 13 14 |
# File 'lib/micro_fire.rb', line 12 def stream @stream end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
27 28 29 |
# File 'lib/micro_fire.rb', line 27 def http @http end |
#json ⇒ Object
Returns the value of attribute json.
28 29 30 |
# File 'lib/micro_fire.rb', line 28 def json @json end |
#pass ⇒ Object
Returns the value of attribute pass.
28 29 30 |
# File 'lib/micro_fire.rb', line 28 def pass @pass end |
#room ⇒ Object (readonly)
Returns the value of attribute room.
27 28 29 |
# File 'lib/micro_fire.rb', line 27 def room @room end |
#stream ⇒ Object
Returns the value of attribute stream.
28 29 30 |
# File 'lib/micro_fire.rb', line 28 def stream @stream end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
27 28 29 |
# File 'lib/micro_fire.rb', line 27 def token @token end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
27 28 29 |
# File 'lib/micro_fire.rb', line 27 def uri @uri end |
Instance Method Details
#join(&block) ⇒ Object
45 46 47 48 |
# File 'lib/micro_fire.rb', line 45 def join &block req action('join'), &block self end |
#speak(message, &block) ⇒ Object
50 51 52 53 |
# File 'lib/micro_fire.rb', line 50 def speak , &block req action('speak'), :message => { :body => }, &block self end |
#watch(&block) ⇒ Object
55 56 57 58 |
# File 'lib/micro_fire.rb', line 55 def watch &block req action('live'), {}, :Get, stream, &block self end |