Class: Tweetkit::Response::Tweets
- Inherits:
-
Object
- Object
- Tweetkit::Response::Tweets
- Includes:
- Enumerable
- Defined in:
- lib/tweetkit/response.rb
Instance Attribute Summary collapse
-
#meta ⇒ Object
Returns the value of attribute meta.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#tweets ⇒ Object
Returns the value of attribute tweets.
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object
-
#initialize(response) ⇒ Tweets
constructor
A new instance of Tweets.
- #last ⇒ Object
- #method_missing(method, **args) ⇒ Object
- #respond_to_missing?(method, *args) ⇒ Boolean
- #to_s ⇒ Object
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
#meta ⇒ Object
Returns the value of attribute meta.
104 105 106 |
# File 'lib/tweetkit/response.rb', line 104 def @meta end |
#resources ⇒ Object
Returns the value of attribute resources.
104 105 106 |
# File 'lib/tweetkit/response.rb', line 104 def resources @resources end |
#tweets ⇒ Object
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 |
#last ⇒ Object
116 117 118 |
# File 'lib/tweetkit/response.rb', line 116 def last tweets.last end |
#respond_to_missing?(method, *args) ⇒ Boolean
128 129 130 |
# File 'lib/tweetkit/response.rb', line 128 def respond_to_missing?(method, *args) tweets.respond_to?(method) end |
#to_s ⇒ Object
120 121 122 |
# File 'lib/tweetkit/response.rb', line 120 def to_s @tweets.join(' ') end |