class Textigniter::Parsers::BlogParser

This class parses for blog content

Public Instance Methods

parse(blogs) click to toggle source
# 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