Class: Datetimepicker::DateAndTimeManipulator

Inherits:
Struct
  • Object
show all
Defined in:
lib/datetimepicker/date_and_time_manipulator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#date_formatObject

Returns the value of attribute date_format

Returns:

  • (Object)

    the current value of date_format



14
15
16
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 14

def date_format
  @date_format
end

#datetimeObject

Returns the value of attribute datetime

Returns:

  • (Object)

    the current value of datetime



14
15
16
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 14

def datetime
  @datetime
end

#time_formatObject

Returns the value of attribute time_format

Returns:

  • (Object)

    the current value of time_format



14
15
16
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 14

def time_format
  @time_format
end

Instance Method Details

#dateObject

Public: get the date component of datetime.

Returns a String in the format of date_format.



19
20
21
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 19

def date
  datetime.strftime(date_format)
end

#date=(new_date) ⇒ Object

Public: set the date component of datetime.

new_date - The String representation of date component for datetime.

The String should be in the format of date_format.


27
28
29
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 27

def date=(new_date)
  self.datetime = parse_date_and_time(new_date, time)
end

#timeObject

Public: get the time component of datetime.

Returns a String in the format of time_format.



34
35
36
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 34

def time
  datetime.strftime(time_format)
end

#time=(new_time) ⇒ Object

Public: set the time component of datetime.

new_time - The String representation of time component for datetime.

The String should be in the format of time_format.


42
43
44
# File 'lib/datetimepicker/date_and_time_manipulator.rb', line 42

def time=(new_time)
  self.datetime = parse_date_and_time(date, new_time)
end