Class: Tweetkit::Response::Tweets::Tweet

Inherits:
Object
  • Object
show all
Defined in:
lib/tweetkit/response.rb

Defined Under Namespace

Classes: Annotations, Attachments, Geo, Metrics

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tweet) ⇒ Tweet

Returns a new instance of Tweet.



100
101
102
103
104
# File 'lib/tweetkit/response.rb', line 100

def initialize(tweet)
  @data = tweet
  @annotations = Annotations.new(data['context_annotations'], data['entities'])
  @attachments = Attachments.new(data['attachments'])
end

Instance Attribute Details

#annotationsObject

Returns the value of attribute annotations.



98
99
100
# File 'lib/tweetkit/response.rb', line 98

def annotations
  @annotations
end

#attachmentsObject

Returns the value of attribute attachments.



98
99
100
# File 'lib/tweetkit/response.rb', line 98

def attachments
  @attachments
end

#dataObject

Returns the value of attribute data.



98
99
100
# File 'lib/tweetkit/response.rb', line 98

def data
  @data
end

Instance Method Details

#author_idObject



114
115
116
# File 'lib/tweetkit/response.rb', line 114

def author_id
  data['author_id']
end

#context_annotationsObject



174
175
176
# File 'lib/tweetkit/response.rb', line 174

def context_annotations
  @annotations.context_annotations || nil
end

#conversation_idObject



118
119
120
# File 'lib/tweetkit/response.rb', line 118

def conversation_id
  data['conversation_id']
end

#created_atObject



122
123
124
# File 'lib/tweetkit/response.rb', line 122

def created_at
  data['created_at']
end

#deviceObject



158
159
160
# File 'lib/tweetkit/response.rb', line 158

def device
  source
end

#entitiesObject



182
183
184
# File 'lib/tweetkit/response.rb', line 182

def entities
  @annotations.entity_annotations || nil
end

#entity_annotationsObject



178
179
180
# File 'lib/tweetkit/response.rb', line 178

def entity_annotations
  entities
end

#idObject



106
107
108
# File 'lib/tweetkit/response.rb', line 106

def id
  data['id']
end

#in_reply_to_user_idObject



130
131
132
# File 'lib/tweetkit/response.rb', line 130

def in_reply_to_user_id
  data['in_reply_to_user_id']
end

#langObject



134
135
136
# File 'lib/tweetkit/response.rb', line 134

def lang
  data['lang']
end

#nsfw?Boolean

Returns:

  • (Boolean)


138
139
140
# File 'lib/tweetkit/response.rb', line 138

def nsfw?
  possibly_sensitive
end

#permissionObject



150
151
152
# File 'lib/tweetkit/response.rb', line 150

def permission
  reply_settings
end

#possibly_sensitiveObject



146
147
148
# File 'lib/tweetkit/response.rb', line 146

def possibly_sensitive
  data['possibly_sensitive']
end

#reply_settingsObject



154
155
156
# File 'lib/tweetkit/response.rb', line 154

def reply_settings
  data['reply_settings']
end

#reply_toObject



126
127
128
# File 'lib/tweetkit/response.rb', line 126

def reply_to
  in_reply_to_user_id
end

#sensitive?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/tweetkit/response.rb', line 142

def sensitive?
  possibly_sensitive
end

#sourceObject



162
163
164
# File 'lib/tweetkit/response.rb', line 162

def source
  data['source']
end

#textObject



110
111
112
# File 'lib/tweetkit/response.rb', line 110

def text
  data['text']
end

#withheldObject



170
171
172
# File 'lib/tweetkit/response.rb', line 170

def withheld
  data['withheld']
end

#withheld?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/tweetkit/response.rb', line 166

def withheld?
  withheld && !withheld.empty?
end