Class: ValidatesTimeliness::Extensions::TimelinessDateTimeSelect::DateTimeValue

Inherits:
Object
  • Object
show all
Defined in:
lib/validates_timeliness/extensions/date_time_select.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dayObject

Returns the value of attribute day.



15
16
17
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15

def day
  @day
end

#hourObject

Returns the value of attribute hour.



15
16
17
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15

def hour
  @hour
end

#minObject

Returns the value of attribute min.



15
16
17
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15

def min
  @min
end

#monthObject

Returns the value of attribute month.



15
16
17
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15

def month
  @month
end

#secObject

Returns the value of attribute sec.



15
16
17
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 15

def sec
  @sec
end

#yearObject

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(options)
  self.class.new(
    year:  options.fetch(:year, year),
    month: options.fetch(:month, month),
    day:   options.fetch(:day, day),
    hour:  options.fetch(:hour, hour),
    min:   options.fetch(:min) { options[:hour] ? 0 : min },
    sec:   options.fetch(:sec) { options[:hour] || options[:min] ? 0 : sec }
  )
end