Class: Tumblargh::Renderer::Blocks::Date

Inherits:
Base show all
Defined in:
lib/tumblargh/renderer/blocks/dates.rb

Overview

Rendered for all posts. Always wrap dates in this block so they will be properly hidden on non-post pages.

Constant Summary collapse

MAP =
{
  # Tumblr tag => strftime symbol
            :day_of_month => '-d',
  :day_of_month_with_zero => :d,
             :day_of_week => :A,
       :short_day_of_week => :a,
      :day_of_week_number => :u,
             :day_of_year => '-j',
            :week_of_year => '-V',
                   :month => :B,
             :short_month => :b,
            :month_number => '-m',
  :month_number_with_zero => :m
}

Instance Attribute Summary

Attributes inherited from Tumblargh::Renderer::Base

#context, #node, #options

Instance Method Summary collapse

Methods inherited from Base

#render, #should_render?

Methods inherited from Tumblargh::Renderer::Base

#context_post, contextual_tag, #escape_html, #escape_url, #initialize, #method_missing, #render, #strip_html

Constructor Details

This class inherits a constructor from Tumblargh::Renderer::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tumblargh::Renderer::Base

Instance Method Details

#day_of_month_suffixObject



32
33
34
# File 'lib/tumblargh/renderer/blocks/dates.rb', line 32

def day_of_month_suffix
  day_of_month.ordinalize
end

#short_yearObject



40
41
42
# File 'lib/tumblargh/renderer/blocks/dates.rb', line 40

def short_year
  year.to_s[2..4]
end

#time_agoObject



44
45
46
47
# File 'lib/tumblargh/renderer/blocks/dates.rb', line 44

def time_ago
  # ActionView::Helpers::DateHelper::time_ago_in_words(date)
  "1 day ago"
end

#yearObject



36
37
38
# File 'lib/tumblargh/renderer/blocks/dates.rb', line 36

def year
  date.year
end