Class: Cldr::Format::Datetime
- Inherits:
-
Object
- Object
- Cldr::Format::Datetime
- Defined in:
- lib/cldr/format/datetime.rb,
lib/cldr/format/datetime/base.rb
Defined Under Namespace
Classes: Base
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #apply(datetime, options = {}) ⇒ Object
-
#initialize(format, date, time) ⇒ Datetime
constructor
A new instance of Datetime.
Constructor Details
#initialize(format, date, time) ⇒ Datetime
Returns a new instance of Datetime.
8 9 10 |
# File 'lib/cldr/format/datetime.rb', line 8 def initialize(format, date, time) @format, @date, @time = format, date, time end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/cldr/format/datetime.rb', line 6 def date @date end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
6 7 8 |
# File 'lib/cldr/format/datetime.rb', line 6 def format @format end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
6 7 8 |
# File 'lib/cldr/format/datetime.rb', line 6 def time @time end |
Instance Method Details
#apply(datetime, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cldr/format/datetime.rb', line 12 def apply(datetime, = {}) format.gsub(/(\{\{(date|time)\}\})/) do case $2 when 'date' [:date] || date.apply(datetime, ) when 'time' [:time] || time.apply(datetime, ) end end end |