Class: PageData
- Inherits:
-
Object
- Object
- PageData
- Defined in:
- lib/botinsta/data/page_data.rb
Overview
Class handling media data. Takes a data object extended Hashie::Extensions::DeepFind
Instance Attribute Summary collapse
-
#all_media ⇒ Object
readonly
Returns the value of attribute all_media.
-
#all_media_count ⇒ Object
readonly
Returns the value of attribute all_media_count.
-
#end_cursor ⇒ Object
readonly
Returns the value of attribute end_cursor.
-
#hashtag_id ⇒ Object
readonly
Returns the value of attribute hashtag_id.
-
#hashtag_name ⇒ Object
readonly
Returns the value of attribute hashtag_name.
-
#media_count ⇒ Object
readonly
Returns the value of attribute media_count.
-
#medias ⇒ Object
readonly
Returns the value of attribute medias.
-
#top_media_count ⇒ Object
readonly
Returns the value of attribute top_media_count.
-
#top_medias ⇒ Object
readonly
Returns the value of attribute top_medias.
Instance Method Summary collapse
- #end_cursor_nil? ⇒ Boolean
-
#initialize(data) ⇒ PageData
constructor
A new instance of PageData.
- #medias_empty? ⇒ Boolean
- #next_page? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ PageData
Returns a new instance of PageData.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/botinsta/data/page_data.rb', line 9 def initialize(data) @hashtag_id = data.deep_find('hashtag')['id'] @hashtag_name = data.deep_find('hashtag')['name'] @has_next_page = data.deep_find('page_info')['has_next_page'] @end_cursor = data.deep_find('end_cursor') @top_medias = data['data']['hashtag']['edge_hashtag_to_top_posts']['edges'] @top_media_count = @top_medias.count @medias = data['data']['hashtag']['edge_hashtag_to_media']['edges'] @media_count = @medias.count + @top_media_count @all_media = @top_medias + @medias @all_media_count = @all_media.count end |
Instance Attribute Details
#all_media ⇒ Object (readonly)
Returns the value of attribute all_media.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def all_media @all_media end |
#all_media_count ⇒ Object (readonly)
Returns the value of attribute all_media_count.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def all_media_count @all_media_count end |
#end_cursor ⇒ Object (readonly)
Returns the value of attribute end_cursor.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def end_cursor @end_cursor end |
#hashtag_id ⇒ Object (readonly)
Returns the value of attribute hashtag_id.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def hashtag_id @hashtag_id end |
#hashtag_name ⇒ Object (readonly)
Returns the value of attribute hashtag_name.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def hashtag_name @hashtag_name end |
#media_count ⇒ Object (readonly)
Returns the value of attribute media_count.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def media_count @media_count end |
#medias ⇒ Object (readonly)
Returns the value of attribute medias.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def medias @medias end |
#top_media_count ⇒ Object (readonly)
Returns the value of attribute top_media_count.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def top_media_count @top_media_count end |
#top_medias ⇒ Object (readonly)
Returns the value of attribute top_medias.
5 6 7 |
# File 'lib/botinsta/data/page_data.rb', line 5 def top_medias @top_medias end |
Instance Method Details
#end_cursor_nil? ⇒ Boolean
28 29 30 |
# File 'lib/botinsta/data/page_data.rb', line 28 def end_cursor_nil? @end_cursor.nil? end |
#medias_empty? ⇒ Boolean
32 33 34 |
# File 'lib/botinsta/data/page_data.rb', line 32 def medias_empty? @medias.empty? end |
#next_page? ⇒ Boolean
24 25 26 |
# File 'lib/botinsta/data/page_data.rb', line 24 def next_page? @has_next_page end |