Class: TimePresenter
- Inherits:
-
Object
- Object
- TimePresenter
- Defined in:
- lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb,
lib/glimmer-dsl-web/samples/hello/hello_input_date_time_data_binding.rb
Instance Attribute Summary collapse
-
#date_time ⇒ Object
Returns the value of attribute date_time.
-
#week_string ⇒ Object
Returns the value of attribute week_string.
Instance Method Summary collapse
- #date_time_string ⇒ Object
- #date_time_string=(value) ⇒ Object
-
#initialize ⇒ TimePresenter
constructor
A new instance of TimePresenter.
Constructor Details
#initialize ⇒ TimePresenter
Returns a new instance of TimePresenter.
7 8 9 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 7 def initialize @date_time = Time.now end |
Instance Attribute Details
#date_time ⇒ Object
Returns the value of attribute date_time.
5 6 7 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 5 def date_time @date_time end |
#week_string ⇒ Object
Returns the value of attribute week_string.
5 6 7 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 5 def week_string @week_string end |
Instance Method Details
#date_time_string ⇒ Object
18 19 20 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 18 def date_time_string @date_time&.strftime('%Y-%m-%dT%H:%M') end |
#date_time_string=(value) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 22 def date_time_string=(value) if value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/) date_time_parts = value.split('T') date_parts = date_time_parts.first.split('-') time_parts = date_time_parts.last.split(':') self.date_time = Time.new(*date_parts, *time_parts) elsif value.strip.empty? self.date_time = nil end end |