Class: AdnHashtagPhotos::GalleryBuilder
- Inherits:
-
Object
- Object
- AdnHashtagPhotos::GalleryBuilder
- Defined in:
- lib/adn_hashtag_photos/gallery_builder.rb
Overview
This class prepares simple objects from ADN posts
Instance Method Summary collapse
- #detect_data(annotations, key_name) ⇒ Object
-
#initialize(hashtag) ⇒ GalleryBuilder
constructor
A new instance of GalleryBuilder.
- #photos ⇒ Array
Constructor Details
#initialize(hashtag) ⇒ GalleryBuilder
Returns a new instance of GalleryBuilder.
7 8 9 10 |
# File 'lib/adn_hashtag_photos/gallery_builder.rb', line 7 def initialize hashtag @posts_loader = PostsLoader.new hashtag @hashtag = hashtag end |
Instance Method Details
#detect_data(annotations, key_name) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/adn_hashtag_photos/gallery_builder.rb', line 33 def detect_data annotations, key_name detected_uploader = Uploader.detect_uploader annotations begin detected_uploader.send key_name rescue raise annotations.inspect end end |
#photos ⇒ Array
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/adn_hashtag_photos/gallery_builder.rb', line 13 def photos posts = @posts_loader.posts.reject do |item| item[:annotations].empty? || item[:annotations].any?{|annotation| annotation[:type] == 'net.app.core.language' } end posts.inject([]) do |memo, post| memo << { content: post[:html], thumbnail_url: detect_data(post[:annotations], :thumbnail_url) } memo end end |