Class: DaFace::Datasift::DaObject
- Inherits:
-
Object
- Object
- DaFace::Datasift::DaObject
- Defined in:
- lib/da_face/datasift/da_object.rb
Constant Summary collapse
- TWITTER_INTERACTION =
:twitter_interaction- TWITTER_DELETE_NOTIFICATION =
:delete_notification- TWITTER_USER_NOTIFICATION =
:user_notification
Instance Attribute Summary collapse
-
#demographic ⇒ Object
readonly
Returns the value of attribute demographic.
-
#interaction ⇒ Object
readonly
Returns the value of attribute interaction.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#salience ⇒ Object
readonly
Returns the value of attribute salience.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
Instance Method Summary collapse
-
#initialize(data = {}, raw_data = {}) ⇒ DaObject
constructor
A new instance of DaObject.
- #notification? ⇒ Boolean
- #set_kind! ⇒ Object
- #twitter_delete_notification? ⇒ Boolean
- #twitter_interaction? ⇒ Boolean
- #twitter_user_status? ⇒ Boolean
Constructor Details
#initialize(data = {}, raw_data = {}) ⇒ DaObject
Returns a new instance of DaObject.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/da_face/datasift/da_object.rb', line 11 def initialize data={}, raw_data={} @raw = raw_data if data[:deleted] @twitter = DaFace::Datasift::TwitterDeleteNotification.new(data) else @twitter = DaFace::Datasift::Twitter.new(data[:twitter]) if data[:twitter] end @interaction = DaFace::Datasift::Interaction.new(data[:interaction]) if data[:interaction] @demographic = DaFace::Datasift::Demographic.new(data[:demographic]) if data[:demographic] @links = DaFace::Datasift::Links.new(data[:links]) if data[:links] @salience = DaFace::Datasift::Salience.new(data[:salience]) if data[:salience] @language = DaFace::Datasift::Language.new(data[:language]) if data[:language] set_kind! if data.any? return self end |
Instance Attribute Details
#demographic ⇒ Object (readonly)
Returns the value of attribute demographic.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def demographic @demographic end |
#interaction ⇒ Object (readonly)
Returns the value of attribute interaction.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def interaction @interaction end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def kind @kind end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def language @language end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def links @links end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def raw @raw end |
#salience ⇒ Object (readonly)
Returns the value of attribute salience.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def salience @salience end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
8 9 10 |
# File 'lib/da_face/datasift/da_object.rb', line 8 def twitter @twitter end |
Instance Method Details
#notification? ⇒ Boolean
40 41 42 |
# File 'lib/da_face/datasift/da_object.rb', line 40 def notification? twitter_delete_notification? || twitter_user_status? end |
#set_kind! ⇒ Object
30 31 32 33 34 |
# File 'lib/da_face/datasift/da_object.rb', line 30 def set_kind! @kind = TWITTER_INTERACTION if @interaction.type == 'twitter' @kind = TWITTER_DELETE_NOTIFICATION if @twitter.class == DaFace::Datasift::TwitterDeleteNotification @kind = TWITTER_USER_NOTIFICATION if @twitter.class == DaFace::Datasift::TwitterUserStatus end |
#twitter_delete_notification? ⇒ Boolean
44 45 46 |
# File 'lib/da_face/datasift/da_object.rb', line 44 def twitter_delete_notification? @kind == TWITTER_DELETE_NOTIFICATION end |
#twitter_interaction? ⇒ Boolean
36 37 38 |
# File 'lib/da_face/datasift/da_object.rb', line 36 def twitter_interaction? @kind == TWITTER_INTERACTION end |
#twitter_user_status? ⇒ Boolean
48 49 50 |
# File 'lib/da_face/datasift/da_object.rb', line 48 def twitter_user_status? @kind == TWITTER_USER_NOTIFICATION end |