Class: TimePresenter
- Inherits:
-
Object
- Object
- TimePresenter
- Defined in:
- lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb
Instance Attribute Summary collapse
-
#date_time ⇒ Object
Returns the value of attribute date_time.
-
#month_string ⇒ Object
Returns the value of attribute month_string.
-
#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.
27 28 29 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 27 def initialize @date_time = Time.now end |
Instance Attribute Details
#date_time ⇒ Object
Returns the value of attribute date_time.
25 26 27 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25 def date_time @date_time end |
#month_string ⇒ Object
Returns the value of attribute month_string.
25 26 27 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25 def month_string @month_string end |
#week_string ⇒ Object
Returns the value of attribute week_string.
25 26 27 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 25 def week_string @week_string end |
Instance Method Details
#date_time_string ⇒ Object
49 50 51 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 49 def date_time_string @date_time&.strftime('%Y-%m-%dT%H:%M') end |
#date_time_string=(value) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/glimmer-dsl-web/samples/hello/hello_input_date_time.rb', line 53 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) end end |