Class: Idiomag::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/idiomag/parser.rb

Class Method Summary collapse

Class Method Details

.parse_articles(article_data) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/idiomag/parser.rb', line 4

def parse_articles(article_data)
  articles = article_data['articles']
  articles.each do |a|
    a.rename_key!('sourceUrl', 'source_url')
    a.keys_to_sym!
    a[:date] = Time.parse(a[:date])
  end
end

.parse_photos(photo_data) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/idiomag/parser.rb', line 13

def parse_photos(photo_data)
  photos = photo_data['photos']
  photos.each do |p|
    p.keys_to_sym!
    p[:date] = Time.parse(p[:date])
  end
end

.parse_playlist(playlist_data) ⇒ Object



26
27
28
29
# File 'lib/idiomag/parser.rb', line 26

def parse_playlist(playlist_data)
  playlist = playlist_data['tracks']
  playlist.each {|v| v.keys_to_sym!}
end

.parse_videos(video_data) ⇒ Object



21
22
23
24
# File 'lib/idiomag/parser.rb', line 21

def parse_videos(video_data)    
  videos = video_data['tracks']
  videos.each {|v| v.keys_to_sym!}
end