Class: ArticleJSON::Export::AppleNews::Exporter
- Inherits:
-
Object
- Object
- ArticleJSON::Export::AppleNews::Exporter
- Defined in:
- lib/article_json/export/apple_news/exporter.rb
Instance Method Summary collapse
-
#initialize(elements) ⇒ Exporter
constructor
A new instance of Exporter.
-
#to_json ⇒ String
Return the components section of an Apple News Article as JSON.
Constructor Details
#initialize(elements) ⇒ Exporter
Returns a new instance of Exporter.
6 7 8 |
# File 'lib/article_json/export/apple_news/exporter.rb', line 6 def initialize(elements) @elements = elements end |
Instance Method Details
#to_json ⇒ String
Return the components section of an Apple News Article as JSON
Images and EmbededVideos are nested in an array with the components array when they contain captions. As Apple News skips over these nested arrays, we must flatten the array.
17 18 19 |
# File 'lib/article_json/export/apple_news/exporter.rb', line 17 def to_json { components: components.flatten }.to_json end |