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.



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

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.



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

def day
  @day
end

#hourObject

Returns the value of attribute hour.



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

def hour
  @hour
end

#minObject

Returns the value of attribute min.



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

def min
  @min
end

#monthObject

Returns the value of attribute month.



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

def month
  @month
end

#secObject

Returns the value of attribute sec.



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

def sec
  @sec
end

#yearObject

Returns the value of attribute year.



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

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)



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

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