Class: ValidatesTimeliness::Extensions::DateTimeSelect::DateTimeValue
- Inherits:
-
Object
- Object
- ValidatesTimeliness::Extensions::DateTimeSelect::DateTimeValue
- Defined in:
- lib/validates_timeliness/extensions/date_time_select.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#min ⇒ Object
Returns the value of attribute min.
-
#month ⇒ Object
Returns the value of attribute month.
-
#sec ⇒ Object
Returns the value of attribute sec.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #change(options) ⇒ Object
-
#initialize(year:, month:, day: nil, hour: nil, min: nil, sec: nil) ⇒ DateTimeValue
constructor
A new instance of DateTimeValue.
Constructor Details
#initialize(year:, month:, day: nil, hour: nil, min: nil, sec: nil) ⇒ DateTimeValue
Returns a new instance of DateTimeValue.
17 18 19 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 17 def initialize(year:, month:, day: nil, hour: nil, min: nil, sec: nil) @year, @month, @day, @hour, @min, @sec = year, month, day, hour, min, sec end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def day @day end |
#hour ⇒ Object
Returns the value of attribute hour.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def hour @hour end |
#min ⇒ Object
Returns the value of attribute min.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def min @min end |
#month ⇒ Object
Returns the value of attribute month.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def month @month end |
#sec ⇒ Object
Returns the value of attribute sec.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def sec @sec end |
#year ⇒ Object
Returns the value of attribute year.
15 16 17 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15 def year @year end |
Instance Method Details
#change(options) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 21 def change() self.class.new( year: .fetch(:year, year), month: .fetch(:month, month), day: .fetch(:day, day), hour: .fetch(:hour, hour), min: .fetch(:min) { [:hour] ? 0 : min }, sec: .fetch(:sec) { [:hour] || [:min] ? 0 : sec } ) end |