Class: TwitterCldr::DataReaders::CalendarDataReader
- Inherits:
-
DataReader
- Object
- DataReader
- TwitterCldr::DataReaders::CalendarDataReader
- Defined in:
- lib/twitter_cldr/data_readers/calendar_data_reader.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_TYPE =
:medium
- TYPE_PATHS =
{ full: [:full, :pattern], long: [:long, :pattern], medium: [:medium, :pattern], short: [:short, :pattern], additional: [:additional_formats] }
Instance Attribute Summary collapse
-
#additional_format ⇒ Object
readonly
Returns the value of attribute additional_format.
-
#calendar_type ⇒ Object
readonly
Returns the value of attribute calendar_type.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from DataReader
Class Method Summary collapse
Instance Method Summary collapse
- #additional_format_selector ⇒ Object
- #calendar ⇒ Object
-
#initialize(locale, options = {}) ⇒ CalendarDataReader
constructor
A new instance of CalendarDataReader.
- #pattern ⇒ Object
Methods inherited from DataReader
Constructor Details
#initialize(locale, options = {}) ⇒ CalendarDataReader
Returns a new instance of CalendarDataReader.
28 29 30 31 32 33 34 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 28 def initialize(locale, = {}) super(locale) @calendar_type = [:calendar_type] || TwitterCldr::DEFAULT_CALENDAR_TYPE @type = [:type] || type || :default @type = DEFAULT_TYPE if type == :default @additional_format = [:additional_format] end |
Instance Attribute Details
#additional_format ⇒ Object (readonly)
Returns the value of attribute additional_format.
26 27 28 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 26 def additional_format @additional_format end |
#calendar_type ⇒ Object (readonly)
Returns the value of attribute calendar_type.
26 27 28 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 26 def calendar_type @calendar_type end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
26 27 28 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 26 def type @type end |
Class Method Details
.types ⇒ Object
21 22 23 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 21 def types TYPE_PATHS.keys end |
Instance Method Details
#additional_format_selector ⇒ Object
48 49 50 51 52 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 48 def additional_format_selector @format_selector ||= AdditionalDateFormatSelector.new( traverse([:calendars, calendar_type, :additional_formats]) ) end |
#calendar ⇒ Object
44 45 46 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 44 def calendar @calendar ||= TwitterCldr::Shared::Calendar.new(locale) end |
#pattern ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/twitter_cldr/data_readers/calendar_data_reader.rb', line 36 def pattern if type == :additional additional_format_selector.find_closest(additional_format) else traverse(path_for(type, calendar_type) + TYPE_PATHS[type]) end end |