Class: Gloo::Objs::Datetime
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Datetime
- Defined in:
- lib/gloo/objs/dt/datetime.rb
Constant Summary collapse
- KEYWORD =
'datetime'.freeze
- KEYWORD_SHORT =
'dt'.freeze
- DEFAULT_FORMAT =
'%Y.%m.%d %I:%M:%S %P'.freeze
Constants inherited from Core::Baseo
Core::Baseo::NOT_IMPLEMENTED_ERR
Instance Attribute Summary
Attributes inherited from Core::Obj
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#msg_is_future ⇒ Object
Tell the datetime to check if it is in the future.
-
#msg_is_past ⇒ Object
Tell the datetime to check if it is in the past.
-
#msg_is_this_week ⇒ Object
Tell the datetime to check if it is this week.
-
#msg_is_today ⇒ Object
Tell the datetime to check if it is today.
-
#msg_is_tomorrow ⇒ Object
Tell the datetime to check if it is tomorrow.
-
#msg_is_yesterday ⇒ Object
Tell the datetime to check if it is yesterday.
-
#msg_now ⇒ Object
Set to the current date and time.
-
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
Methods inherited from Core::Obj
#add_child, #add_children_on_create?, #add_default_children, can_create?, #can_receive_message?, #child_count, #child_index, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, #find_child_resolve_alias, #find_child_value, help, inherited, #initialize, #is_alias?, #is_function?, #msg_blank?, #msg_contains?, #msg_reload, #msg_unload, #multiline_value?, #pn, #remove_child, #render, #root?, #send_message, #set_parent, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?
Methods inherited from Core::Baseo
Constructor Details
This class inherits a constructor from Gloo::Core::Obj
Class Method Details
.messages ⇒ Object
Get a list of message names that this object receives.
52 53 54 |
# File 'lib/gloo/objs/dt/datetime.rb', line 52 def self. return super + %w[now is_today is_future is_past is_yesterday is_tomorrow is_this_week] end |
.short_typename ⇒ Object
The short name of the object type.
26 27 28 |
# File 'lib/gloo/objs/dt/datetime.rb', line 26 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
19 20 21 |
# File 'lib/gloo/objs/dt/datetime.rb', line 19 def self.typename return KEYWORD end |
Instance Method Details
#msg_is_future ⇒ Object
Tell the datetime to check if it is in the future.
68 69 70 71 72 |
# File 'lib/gloo/objs/dt/datetime.rb', line 68 def msg_is_future today = DtTools.is_future?( self.value ) @engine.heap.it.set_to today return today end |
#msg_is_past ⇒ Object
Tell the datetime to check if it is in the past.
77 78 79 80 81 |
# File 'lib/gloo/objs/dt/datetime.rb', line 77 def msg_is_past today = DtTools.is_past?( self.value ) @engine.heap.it.set_to today return today end |
#msg_is_this_week ⇒ Object
Tell the datetime to check if it is this week.
104 105 106 107 108 |
# File 'lib/gloo/objs/dt/datetime.rb', line 104 def msg_is_this_week today = DtTools.is_this_week?( self.value ) @engine.heap.it.set_to today return today end |
#msg_is_today ⇒ Object
Tell the datetime to check if it is today.
59 60 61 62 63 |
# File 'lib/gloo/objs/dt/datetime.rb', line 59 def msg_is_today today = DtTools.is_today?( self.value ) @engine.heap.it.set_to today return today end |
#msg_is_tomorrow ⇒ Object
Tell the datetime to check if it is tomorrow.
95 96 97 98 99 |
# File 'lib/gloo/objs/dt/datetime.rb', line 95 def msg_is_tomorrow today = DtTools.is_tomorrow?( self.value ) @engine.heap.it.set_to today return today end |
#msg_is_yesterday ⇒ Object
Tell the datetime to check if it is yesterday.
86 87 88 89 90 |
# File 'lib/gloo/objs/dt/datetime.rb', line 86 def msg_is_yesterday today = DtTools.is_yesterday?( self.value ) @engine.heap.it.set_to today return today end |
#msg_now ⇒ Object
Set to the current date and time.
113 114 115 116 |
# File 'lib/gloo/objs/dt/datetime.rb', line 113 def msg_now self.set_value( DateTime.now ) @engine.heap.it.set_to self.value end |
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gloo/objs/dt/datetime.rb', line 33 def set_value( new_value ) if DtTools.is_dt_type? new_value self.value = new_value else self.value = @engine.converter.convert( new_value, 'DateTime', nil ) end if DtTools.is_dt_type? self.value self.value = self.value.strftime( DEFAULT_FORMAT ) end end |