hrstt
6/25/2011 - 1:41 PM

For Nanoc, Select specific kind items.

For Nanoc, Select specific kind items.

module ItemList
  # select specific kind items
  # select items by "kind" which is one of item attributes.
  # result list sort by created_at
  def sorted_list(kind)
    @items.select {|i|
      i[:kind] == kind
    }.sort_by {|a|
      if a[:created_at].class == Time then
        a[:created_at]
      else
        Time.parse(a[:created_at])
      end
    }
  end
end

include ItemList