-
-
Save brdrgz/128c8816bca94c3ebe26 to your computer and use it in GitHub Desktop.
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
class ActivityFeedDateRange < ActivityFeedDate | |
def valid? | |
start_date.present? && end_date.present? | |
end | |
def render | |
day_range = "#{start_date.day}-#{end_date.day}" | |
template.content_tag(:div, :class => "range-date-row") do | |
template.render partial: 'shared/activity_feed_date_range', locals: { month: start_date.strftime('%b'), day_range: day_range, year: start_date.year } | |
end | |
end | |
end | |
class ActivityFeedSingleDate < ActivityFeedDate | |
def valid? | |
start_date.day == end_date.day | |
end | |
def render | |
template.content_tag(:div, :class => "single-date-row") do | |
template.render partial: 'shared/activity_feed_date', locals: { month: start_date.strftime('%b'), day: start_date.day, year: start_date.year } | |
end | |
end | |
end | |
class ActivityFeedDate | |
include TemplateHelper | |
include ValidRenderable | |
attr_reader :start_date, :end_date | |
def initialize start_date, end_date | |
@start_date = start_date | |
@end_date = end_date | |
end | |
end | |
module ValidRenderable | |
def valid? | |
false | |
end | |
def render | |
end | |
end |
Author
brdrgz
commented
Sep 30, 2015
def renderable_date_types
[
ActivityFeedVariedDates,
ActivityFeedSingleDate,
ActivityFeedDateRange
]
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment