Skip to content

Instantly share code, notes, and snippets.

@hrstt
Created June 25, 2011 13:41
Show Gist options
  • Save hrstt/1046502 to your computer and use it in GitHub Desktop.
Save hrstt/1046502 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment