class TwitterCldr::Shared::DayPeriods::FromRule

Public Instance Methods

<=>(other) click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 47
def <=>(other)
  return 1 if other.params[:at]

  timespan <=> other.timespan
end
before() click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 67
def before
  @before ||= Timestamp.new(
    params[:before][:hour], params[:before][:min], 0
  )
end
from() click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 61
def from
  @from ||= Timestamp.new(
    params[:from][:hour], params[:from][:min], 0
  )
end
matches?(timestamp) click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 73
def matches?(timestamp)
  if from > before
    timestamp >= from || timestamp < before
  else
    timestamp >= from && timestamp < before
  end
end
timespan() click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 53
def timespan
  @timespan ||= if from > before
    (24 - from.to_f) + before.to_f
  else
    before.to_f - from.to_f
  end
end