module TheCity::Time
Public Instance Methods
created?()
click to toggle source
# File lib/the_city/time.rb, line 15 def created? !!@attrs[:created_at] end
created_at()
click to toggle source
Time
when the object was created
@return [Time]
# File lib/the_city/time.rb, line 11 def created_at @created_at ||= parse_or_at(@attrs[:created_at]) if @attrs[:created_at] end
ended?()
click to toggle source
# File lib/the_city/time.rb, line 48 def ended? !!@attrs[:ending_at] and ending_at <= Time.now end
ending_at()
click to toggle source
Time
when the object ends
@return [Time]
# File lib/the_city/time.rb, line 44 def ending_at @ending_at ||= parse_or_at(@attrs[:ending_at]) if @attrs[:ending_at] end
started?()
click to toggle source
# File lib/the_city/time.rb, line 37 def started? !!@attrs[:starting_at] and starting_at <= Time.now end
starting_at()
click to toggle source
Time
when the object starts
@return [Time]
# File lib/the_city/time.rb, line 33 def starting_at @starting_at ||= parse_or_at(@attrs[:starting_at]) if @attrs[:starting_at] end
updated?()
click to toggle source
# File lib/the_city/time.rb, line 26 def updated? !!@attrs[:updated_at] end
updated_at()
click to toggle source
Time
when the object was updated
@return [Time]
# File lib/the_city/time.rb, line 22 def updated_at @updated_at ||= parse_or_at(@attrs[:updated_at]) if @attrs[:updated_at] end
Private Instance Methods
parse_or_at(time)
click to toggle source
# File lib/the_city/time.rb, line 54 def parse_or_at(time) begin if time.is_a? Integer return Time.at(time).utc else return Time.parse(time).utc end rescue return nil end end