Class: Flamingo::Stream
- Inherits:
-
Object
- Object
- Flamingo::Stream
- Defined in:
- lib/flamingo/stream.rb
Constant Summary collapse
- VERSION =
1
- RESOURCES =
HashWithIndifferentAccess.new( :filter => "statuses/filter", :firehose => "statuses/firehose", :retweet => "statuses/retweet", :sample => "statuses/sample" )
- DEFAULT_CONNECTION_OPTIONS =
{ :method =>"POST", :ssl => false, :user_agent => "Flamingo/#{Flamingo::VERSION}" }
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#params ⇒ Object
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #connect(options) ⇒ Object
- #connection_options(overrides = {}) ⇒ Object
-
#initialize(name, params) ⇒ Stream
constructor
A new instance of Stream.
- #path ⇒ Object
- #query ⇒ Object
- #resource ⇒ Object
- #to_json ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, params) ⇒ Stream
Returns a new instance of Stream.
28 29 30 31 |
# File 'lib/flamingo/stream.rb', line 28 def initialize(name,params) self.name = name self.params = params end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/flamingo/stream.rb', line 26 def name @name end |
#params ⇒ Object
Returns the value of attribute params.
26 27 28 |
# File 'lib/flamingo/stream.rb', line 26 def params @params end |
Class Method Details
.get(name) ⇒ Object
21 22 23 |
# File 'lib/flamingo/stream.rb', line 21 def get(name) new(name,StreamParams.new(name)) end |
Instance Method Details
#connect(options) ⇒ Object
33 34 35 |
# File 'lib/flamingo/stream.rb', line 33 def connect() Twitter::JSONStream.connect(()) end |
#connection_options(overrides = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/flamingo/stream.rb', line 37 def (overrides={}) DEFAULT_CONNECTION_OPTIONS. merge(overrides). merge(:path=>path,:content=>query) end |
#path ⇒ Object
43 44 45 |
# File 'lib/flamingo/stream.rb', line 43 def path "/#{VERSION}/#{resource}.json" end |
#query ⇒ Object
57 58 59 |
# File 'lib/flamingo/stream.rb', line 57 def query params.map{|key,value| "#{key}=#{param_value(value)}" }.join("&") end |
#resource ⇒ Object
47 48 49 |
# File 'lib/flamingo/stream.rb', line 47 def resource RESOURCES[name.to_sym] end |
#to_json ⇒ Object
51 52 53 54 55 |
# File 'lib/flamingo/stream.rb', line 51 def to_json ActiveSupport::JSON.encode( :name=>name,:resource=>resource,:params=>params.all ) end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/flamingo/stream.rb', line 61 def to_s "#{path}?#{query}" end |