Class: Textigniter::Parsers::BlogParser
- Inherits:
-
Object
- Object
- Textigniter::Parsers::BlogParser
- Defined in:
- lib/textigniter/parsers/blog_parser.rb
Overview
This class parses for blog content
Instance Method Summary collapse
Instance Method Details
#parse(blogs) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/textigniter/parsers/blog_parser.rb', line 4 def parse(blogs) # blog keys blog_keys = Hash.new # create blog keys blogs.each do |item| blog_keys["#{item['blog']}"] = nil end # iterate through blog keys and assign appropriate posts blog_keys.each do |key,value| # create a blog item list blog_items = Array.new # iterate through blogs blogs.each do |item| # match keys if item['blog'] == key # push the item blog_items.push item end end blog_keys["#{key}"] = blog_items end # return the blogs keyed with correct info return blog_keys end |