Class: PageData

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_mediaObject (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_countObject (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_cursorObject (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_idObject (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_nameObject (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_countObject (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

#mediasObject (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_countObject (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_mediasObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/botinsta/data/page_data.rb', line 28

def end_cursor_nil?
  @end_cursor.nil?
end

#medias_empty?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/botinsta/data/page_data.rb', line 32

def medias_empty?
  @medias.empty?
end

#next_page?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/botinsta/data/page_data.rb', line 24

def next_page?
  @has_next_page
end