Class: Worldwide::Cldr::DateFormatPattern::Field
- Inherits:
-
Object
- Object
- Worldwide::Cldr::DateFormatPattern::Field
- Defined in:
- lib/worldwide/cldr/date_format_pattern.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
Returns the value of attribute pattern.
Class Method Summary collapse
Instance Method Summary collapse
- #format(date, locale: I18n.locale) ⇒ Object
-
#initialize(pattern) ⇒ Field
constructor
A new instance of Field.
Constructor Details
#initialize(pattern) ⇒ Field
Returns a new instance of Field.
91 92 93 |
# File 'lib/worldwide/cldr/date_format_pattern.rb', line 91 def initialize(pattern) @pattern = pattern end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
Returns the value of attribute pattern.
89 90 91 |
# File 'lib/worldwide/cldr/date_format_pattern.rb', line 89 def pattern @pattern end |
Class Method Details
.from(pattern) ⇒ Object
83 84 85 86 |
# File 'lib/worldwide/cldr/date_format_pattern.rb', line 83 def from(pattern) klass = Worldwide::Cldr::DateFormatPattern::FIELD_CLASSES[pattern[0].to_sym] || Field klass.new(pattern) end |
Instance Method Details
#format(date, locale: I18n.locale) ⇒ Object
95 96 97 |
# File 'lib/worldwide/cldr/date_format_pattern.rb', line 95 def format(date, locale: I18n.locale) raise NotImplementedError, "Unimplemented field: #{pattern}" end |