class TwitterCldr::Shared::DayPeriods
Attributes
locale[R]
rule_set[R]
Public Class Methods
instance(locale)
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 105 def instance(locale) instance_cache[locale] ||= new(locale) end
new(locale, rule_set = :default)
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 124 def initialize(locale, rule_set = :default) @locale = locale @rule_set = rule_set end
Private Class Methods
instance_cache()
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 111 def instance_cache @instance_cache ||= {} end
Public Instance Methods
period_type_for(time)
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 118 def period_type_for(time) timestamp = Timestamp.new(time.hour, time.min, time.sec) rule = rules.find { |rule| rule.matches?(timestamp) } rule.name end
Private Instance Methods
resource()
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 137 def resource TwitterCldr.get_locale_resource(locale, :day_periods)[locale] end
rules()
click to toggle source
# File lib/twitter_cldr/shared/day_periods.rb, line 131 def rules @rules ||= resource[rule_set].map do |name, params| Rule.create(name, params) end.sort end