Class: GlooLang::Objs::Text

Inherits:
Core::Obj show all
Defined in:
lib/gloo_lang/objs/basic/text.rb

Constant Summary collapse

KEYWORD =
'text'.freeze
KEYWORD_SHORT =
'txt'.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, #contains_child?, #delete_children, #dispatch, #display_value, #find_add_child, #find_child, help, inherited, #initialize, #msg_reload, #msg_unload, #pn, #remove_child, #root?, #send_message, #set_parent, #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 GlooLang::Core::Obj

Class Method Details

.messagesObject

Get a list of message names that this object receives.



57
58
59
# File 'lib/gloo_lang/objs/basic/text.rb', line 57

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

.short_typenameObject

The short name of the object type.



24
25
26
# File 'lib/gloo_lang/objs/basic/text.rb', line 24

def self.short_typename
  return KEYWORD_SHORT
end

.typenameObject

The name of the object type.



17
18
19
# File 'lib/gloo_lang/objs/basic/text.rb', line 17

def self.typename
  return KEYWORD
end

Instance Method Details

#line_countObject

Get the number of lines of text.



46
47
48
# File 'lib/gloo_lang/objs/basic/text.rb', line 46

def line_count
  return value.split( "\n" ).count
end

#msg_editObject

Edit the text in the default editor.



73
74
75
# File 'lib/gloo_lang/objs/basic/text.rb', line 73

def msg_edit
  self.value = @engine.platform.edit( self.value )
end

#msg_pageObject

Show the contents of the file, paginated.



64
65
66
67
68
# File 'lib/gloo_lang/objs/basic/text.rb', line 64

def msg_page
  return unless value

  @engine.platform.show( value, false, true )
end

#multiline_value?Boolean

Does this object support multi-line values? Initially only true for scripts.

Returns:



39
40
41
# File 'lib/gloo_lang/objs/basic/text.rb', line 39

def multiline_value?
  return false
end

#set_value(new_value) ⇒ Object

Set the value with any necessary type conversions.



31
32
33
# File 'lib/gloo_lang/objs/basic/text.rb', line 31

def set_value( new_value )
  self.value = new_value.to_s
end