Class: ValidatesTimeliness::Extensions::DateTimeSelect::TimelinessDateTime

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, hour, min, sec) ⇒ TimelinessDateTime

Returns a new instance of TimelinessDateTime.



18
19
20
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 18

def initialize(year, month, day, hour, min, sec)
  @year, @month, @day, @hour, @min, @sec = year, month, day, hour, min, sec
end

Instance Attribute Details

#dayObject

Returns the value of attribute day.



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

def day
  @day
end

#hourObject

Returns the value of attribute hour.



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

def hour
  @hour
end

#minObject

Returns the value of attribute min.



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

def min
  @min
end

#monthObject

Returns the value of attribute month.



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

def month
  @month
end

#secObject

Returns the value of attribute sec.



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

def sec
  @sec
end

#yearObject

Returns the value of attribute year.



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

def year
  @year
end

Instance Method Details

#change(options) ⇒ Object

adapted from activesupport/lib/active_support/core_ext/date_time/calculations.rb, line 36 (3.0.7)



23
24
25
26
27
28
29
30
31
32
# File 'lib/validates_timeliness/extensions/date_time_select.rb', line 23

def change(options)
  TimelinessDateTime.new(
    options[:year]  || year,
    options[:month] || month,
    options[:day]   || day,
    options[:hour]  || hour,
    options[:min]   || (options[:hour] ? 0 : min),
    options[:sec]   || ((options[:hour] || options[:min]) ? 0 : sec)
  )
end