Created
June 25, 2011 13:41
-
-
Save hrstt/1046502 to your computer and use it in GitHub Desktop.
For Nanoc, Select specific kind items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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