lib/pupil/stream/base.rb in pupil-0.1.5 vs lib/pupil/stream/base.rb in pupil-0.2.0

- old
+ new

@@ -3,10 +3,12 @@ attr_reader :screen_name STREAM_APIS = { :userstream => "https://userstream.twitter.com/2/user.json", :search => "https://stream.twitter.com/1/statuses/filter.json%s" } + + include Essentials def initialize key @screen_name = key[:screen_name] @consumer = OAuth::Consumer.new( @@ -27,11 +29,11 @@ run_get_stream type, param, &block end def run_get_stream(type, param=nil, &block) - uri = URI.parse(STREAM_APIS[type] % Pupil.param_serializer(param)) + uri = URI.parse(STREAM_APIS[type] % serialize_parameter(param)) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true https.verify_mode = OpenSSL::SSL::VERIFY_NONE https.verify_depth = 5 @@ -68,26 +70,26 @@ elsif status["friends"] return Pupil::Stream::Array.new(status["friends"], :friends) elsif status["event"] == "favorite" return Pupil::Stream::Hash.new(status, :favorite) elsif status["retweeted_status"] - return Pupil::Stream::Status.new(status, :retweeted) + return Pupil::Stream::Status.new(status, @access_token, :retweeted) elsif status["text"] - return Pupil::Stream::Status.new(status) + return Pupil::Stream::Status.new(status, @access_token) else return Pupil::Stream::Hash.new(status, :unknown) end end # Stream Status class Status < Pupil::Status attr_reader :event attr_reader :retweeted_status - def initialize(status, event=nil) - super(status) + def initialize(status, access_token, event=nil) + super(status, access_token) @event = (event)? event : :status - @retweeted_status = status["retweeted_status"] + #@retweeted_status = status["retweeted_status"] end end # Stream Hash class Hash < Hash