Module: Jekyll::Filters
- Defined in:
- lib/hj7/tagging.rb
Instance Method Summary collapse
- #month_name(month_number) ⇒ Object
- #ordinal(num) ⇒ Object
- #tag_url(tag, dir = "tags") ⇒ Object
- #tags(obj) ⇒ Object
Instance Method Details
#month_name(month_number) ⇒ Object
31 32 33 34 |
# File 'lib/hj7/tagging.rb', line 31 def month_name(month_number) month_number = month_number.to_i Date::MONTHNAMES[month_number] end |
#ordinal(num) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hj7/tagging.rb', line 17 def ordinal(num) num = num.to_i case num % 100 when 11..13; "#{num}th" else case num % 10 when 1; "#{num}st" when 2; "#{num}nd" when 3; "#{num}rd" else "#{num}th" end end end |
#tag_url(tag, dir = "tags") ⇒ Object
8 9 10 |
# File 'lib/hj7/tagging.rb', line 8 def tag_url(tag, dir = "tags") "/#{dir}/#{ERB::Util.u(tag)}" end |
#tags(obj) ⇒ Object
12 13 14 15 |
# File 'lib/hj7/tagging.rb', line 12 def (obj) = obj["tags"][0].is_a?(Array) ? obj["tags"].map{ |t| t[0]} : obj["tags"] .map { |t| tag_link(t, tag_url(t)) if t.is_a?(String) }.compact.join(" ") end |