Class: Gloo::Objs::Boolean
- Inherits:
- 
      Core::Obj
      
        - Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Boolean
 
- Defined in:
- lib/gloo/objs/basic/boolean.rb
Constant Summary collapse
- KEYWORD =
- 'boolean'.freeze 
- KEYWORD_SHORT =
- 'bool'.freeze 
- TRUE =
- 'true'.freeze 
- FALSE =
- 'false'.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
- 
  
    
      .boolean?(token)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is the given token a boolean?. 
- 
  
    
      .coerse_to_bool(new_value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Coerse the new value to a boolean value. 
- 
  
    
      .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_false  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the value to false. 
- 
  
    
      #msg_not  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the value to the opposite of what it is. 
- 
  
    
      #msg_true  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the value to true. 
- 
  
    
      #set_value(new_value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Set the value with any necessary type conversions. 
- 
  
    
      #value_display  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Get the value for display purposes. 
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, help, inherited, #initialize, #is_alias?, #is_function?, #msg_reload, #msg_unload, #multiline_value?, #pn, #remove_child, #render, #root?, #send_message, #set_parent, #type_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
.boolean?(token) ⇒ Boolean
Is the given token a boolean?
| 61 62 63 64 65 66 67 68 69 70 | # File 'lib/gloo/objs/basic/boolean.rb', line 61 def self.boolean?( token ) return true if token == true return true if token == false if token.class.name == 'String' return true if token.strip.downcase == TRUE return true if token.strip.downcase == FALSE end return false end | 
.coerse_to_bool(new_value) ⇒ Object
Coerse the new value to a boolean value.
| 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # File 'lib/gloo/objs/basic/boolean.rb', line 40 def self.coerse_to_bool( new_value ) return false if new_value.nil? # I should be able to use this: # if new_value.kind_of?( String ) # but it doesn't work. I don't know why. if new_value.class.name == 'String' return true if new_value.strip.downcase == TRUE return false if new_value.strip.downcase == FALSE return true if new_value.strip.downcase == 't' return false if new_value.strip.downcase == 'f' elsif new_value.class.name == 'Integer' return new_value.zero? ? false : true end return new_value == true end | 
.messages ⇒ Object
Get a list of message names that this object receives.
| 86 87 88 | # File 'lib/gloo/objs/basic/boolean.rb', line 86 def self. return super + %w[not true false] end | 
.short_typename ⇒ Object
The short name of the object type.
| 26 27 28 | # File 'lib/gloo/objs/basic/boolean.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/basic/boolean.rb', line 19 def self.typename return KEYWORD end | 
Instance Method Details
#msg_false ⇒ Object
Set the value to false.
| 112 113 114 115 116 | # File 'lib/gloo/objs/basic/boolean.rb', line 112 def msg_false set_value false @engine.heap.it.set_to false return false end | 
#msg_not ⇒ Object
Set the value to the opposite of what it is.
| 93 94 95 96 97 98 | # File 'lib/gloo/objs/basic/boolean.rb', line 93 def msg_not v = !value set_value v @engine.heap.it.set_to v return v end | 
#msg_true ⇒ Object
Set the value to true.
| 103 104 105 106 107 | # File 'lib/gloo/objs/basic/boolean.rb', line 103 def msg_true set_value true @engine.heap.it.set_to true return true end | 
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
| 33 34 35 | # File 'lib/gloo/objs/basic/boolean.rb', line 33 def set_value( new_value ) self.value = Gloo::Objs::Boolean.coerse_to_bool( new_value ) end |