Created
December 15, 2008 22:18
-
-
Save quirkey/36112 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Portfolio | |
| class Project < StaticModel::Base | |
| set_data_file File.join('data', 'projects.yml') | |
| def to_s | |
| "#{title}" | |
| end | |
| def category_classes | |
| classes = [] | |
| classes.concat technologies.compact.collect {|t| "tech_#{t.gsub(' ', '_')}" } | |
| classes.concat features.compact.collect {|t| "feature_#{t.gsub(' ', '_')}" } | |
| classes << "year_#{launched_at.year}" if launched_at | |
| classes | |
| end | |
| def description | |
| @attributes['description'] || '' | |
| end | |
| def project_type | |
| @attributes['project_type'] || nil | |
| end | |
| def launched_at | |
| launched ? Time.parse(launched) : false | |
| end | |
| def launched | |
| @attributes['launched'] || false | |
| end | |
| def links | |
| Array(@attributes['links']).collect do |l| | |
| link, link_text = l.split('|') | |
| link_text ||= link | |
| [link_text, link] | |
| end | |
| end | |
| class << self | |
| def technologies | |
| @technologies ||= self.all.collect {|p| p.technologies.compact }.flatten.uniq.sort | |
| end | |
| def features | |
| @features ||= self.all.collect {|p| p.features.compact }.flatten.uniq.sort | |
| end | |
| def years | |
| @years ||= self.all.collect {|p| p.launched_at.year if p.launched_at }.compact.uniq.sort | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment