Class: Tweetkit::Response::Tweets

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Tweets

Returns a new instance of Tweets.



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

def initialize(response)
  @tweets = response['data'] ? response['data'].collect { |tweet| Tweetkit::Response::Tweet.new(tweet) } : []
  @meta = response['meta']
  @resources = response['includes']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, **args) ⇒ Object



124
125
126
# File 'lib/tweetkit/response.rb', line 124

def method_missing(method, **args)
  tweets.public_send(method, **args)
end

Instance Attribute Details

#metaObject

Returns the value of attribute meta.



104
105
106
# File 'lib/tweetkit/response.rb', line 104

def meta
  @meta
end

#resourcesObject

Returns the value of attribute resources.



104
105
106
# File 'lib/tweetkit/response.rb', line 104

def resources
  @resources
end

#tweetsObject

Returns the value of attribute tweets.



104
105
106
# File 'lib/tweetkit/response.rb', line 104

def tweets
  @tweets
end

Instance Method Details

#each(*args, &block) ⇒ Object



112
113
114
# File 'lib/tweetkit/response.rb', line 112

def each(*args, &block)
  tweets.each(*args, &block)
end

#lastObject



116
117
118
# File 'lib/tweetkit/response.rb', line 116

def last
  tweets.last
end

#respond_to_missing?(method, *args) ⇒ Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/tweetkit/response.rb', line 128

def respond_to_missing?(method, *args)
  tweets.respond_to?(method)
end

#to_sObject



120
121
122
# File 'lib/tweetkit/response.rb', line 120

def to_s
  @tweets.join(' ')
end