Class: Gloo::Objs::Text
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::Text
- Includes:
- StringMsgs
- Defined in:
- lib/gloo/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
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the object's documentation data.
-
.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
-
#line_count ⇒ Object
Get the number of lines of text.
-
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
-
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
Methods included from StringMsgs
#msg_count_chars, #msg_count_lines, #msg_count_words, #msg_decode64, #msg_down, #msg_encode64, #msg_ends_with?, #msg_escape, #msg_format_for_html, #msg_gen_alphanumeric, #msg_gen_base64, #msg_gen_hex, #msg_gen_uuid, #msg_gsub, #msg_page, #msg_size, #msg_starts_with?, #msg_sub, #msg_substring?, #msg_trim, #msg_unescape, #msg_up
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_responds_to?, #msg_unload, #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
Constructor Details
This class inherits a constructor from Gloo::Core::Obj
Class Method Details
.doc_data ⇒ Object
Get the object's documentation data.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/gloo/objs/basic/text.rb', line 71 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'A longer, multi-line text string. Use BEGIN ' \ 'and END to mark the text range.', :messages => [ 'Same messages as the string object type:', 'up — Convert the string to uppercase. This message changes the value of the string.', 'down — Convert the string to lowercase. This message changes the value of the string.', 'size — Get the size of the string. It will have the string size.', 'count_chars — Count the number of characters in the string. It will have the character count.', 'count_words — Count the number of words in the string. It will have the word count.', 'count_lines — Count the number of lines in the string. It will have the line count.', 'starts_with? ({str}) — Check if the string starts with the given string. A parameter is required: the string to look for at the beginning of this string. It will have a boolean.', 'ends_with? ({str}) — Check if the string ends with the given string. A parameter is required: the string to look for at the end of this string. It will have a boolean.', 'substring? ({str}) — Check if the string includes the given sub-string. A parameter is required: the string to look for in this string. It will have a boolean.', 'format_for_html — Format this string for HTML output. Tabs, spaces and returns are converted to HTML elements. The value of the string is changed.', 'encode64 — Base64 encode the string. This message changes the value of the string. It will have the encoded string.', 'decode64 — Decode the string from Base64. This message changes the value of the string. It will have the decoded string.', 'escape — Escape the string to make it URL safe. This message changes the value of the string. It will have the escaped string.', 'unescape — Unescape the string (from URL safe format). This message changes the value of the string. It will have the unescaped string.', 'gen_uuid — Set the value of the string to a newly generated, random UUID. This message changes the value of the string.', 'gen_alphanumeric ({len}) — Set the value of the string to a newly generated, random alphanumeric string. The {len} parameter is optional; the length is 10 if not specified. This message changes the value of the string.', 'gen_hex ({len}) — Set the value of the string to a newly generated, random hex string. The {len} parameter is optional; the length is 10 if not specified. This message changes the value of the string.', 'gen_base64 ({len}) — Set the value of the string to a newly generated, random base64 string. The {len} parameter is optional; the length is 12 if not specified. This message changes the value of the string.', 'trim — Strip whitespace from the beginning and end of the string. This message changes the value of the string. It will have the trimmed string.', 'sub ({from}, {to}) — Substitute the first occurrence of {from} with {to}. Both parameters are required. This message changes the value of the string. It will have the result.', 'gsub ({from}, {to}) — Substitute all occurrences of {from} with {to}. Both parameters are required. This message changes the value of the string. It will have the result.', 'page — Show the value in a pager (less), for viewing long content a screen at a time.' ], :examples => <<~EXAMPLES.strip t [container] : msg [txt] : BEGIN I will now write a poem of two lines or less END on_load [script] : show t.msg EXAMPLES } end |
.messages ⇒ Object
Get a list of message names that this object receives.
60 61 62 |
# File 'lib/gloo/objs/basic/text.rb', line 60 def self. return super + StringMsgs. end |
.short_typename ⇒ Object
The short name of the object type.
27 28 29 |
# File 'lib/gloo/objs/basic/text.rb', line 27 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
20 21 22 |
# File 'lib/gloo/objs/basic/text.rb', line 20 def self.typename return KEYWORD end |
Instance Method Details
#line_count ⇒ Object
Get the number of lines of text.
49 50 51 |
# File 'lib/gloo/objs/basic/text.rb', line 49 def line_count return value.split( "\n" ).count end |
#multiline_value? ⇒ Boolean
Does this object support multi-line values? Initially only true for scripts.
42 43 44 |
# File 'lib/gloo/objs/basic/text.rb', line 42 def multiline_value? return false end |
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
34 35 36 |
# File 'lib/gloo/objs/basic/text.rb', line 34 def set_value( new_value ) self.value = new_value.to_s end |