Class: Twitter::Streaming::MessageParser

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter/streaming/message_parser.rb

Class Method Summary collapse

Class Method Details

.parse(data) ⇒ Object

rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/twitter/streaming/message_parser.rb', line 11

def self.parse(data) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  if data[:id]
    Tweet.new(data)
  elsif data[:event]
    Event.new(data)
  elsif data[:direct_message]
    DirectMessage.new(data[:direct_message])
  elsif data[:friends]
    FriendList.new(data[:friends])
  elsif data[:delete] && data[:delete][:status]
    DeletedTweet.new(data[:delete][:status])
  elsif data[:warning]
    StallWarning.new(data[:warning])
  end
end