Class: Gloo::Objs::Date

Inherits:
Core::Obj show all
Defined in:
lib/gloo/objs/dt/date.rb

Constant Summary collapse

KEYWORD =
'date'.freeze
KEYWORD_SHORT =
'date'.freeze
DEFAULT_FORMAT =
'%Y.%m.%d'.freeze

Constants inherited from Core::Baseo

Core::Baseo::NOT_IMPLEMENTED_ERR

Instance Attribute Summary

Attributes inherited from Core::Obj

#children, #parent, #value

Attributes inherited from Core::Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

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_container?, #is_function?, #msg_blank?, #msg_contains?, #msg_reload, #msg_unload, #multiline_value?, #pn, #remove_child, #render, #root?, #send_message, #set_parent, #sql_value, #type_display, #value_display, #value_is_array?, #value_is_blank?, #value_string?

Methods inherited from Core::Baseo

#initialize, #type_display

Constructor Details

This class inherits a constructor from Gloo::Core::Obj

Class Method Details

.messagesObject

Get a list of message names that this object receives.



51
52
53
# File 'lib/gloo/objs/dt/date.rb', line 51

def self.messages
  return super + %w[now]
end

.short_typenameObject

The short name of the object type.



25
26
27
# File 'lib/gloo/objs/dt/date.rb', line 25

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



18
19
20
# File 'lib/gloo/objs/dt/date.rb', line 18

def self.typename
  return KEYWORD
end

Instance Method Details

#msg_nowObject

Set to the current date.



58
59
60
61
# File 'lib/gloo/objs/dt/date.rb', line 58

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.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gloo/objs/dt/date.rb', line 32

def set_value( new_value )
  if DtTools.is_dt_type? new_value
    self.value = new_value
  else
    self.value = @engine.converter.convert( new_value, 'Date', nil )
  end

  if DtTools.is_dt_type? self.value
    self.value = self.value.strftime( DEFAULT_FORMAT )
  end
end