Class: Gloo::Objs::String
- Inherits:
-
Core::Obj
- Object
- Core::Baseo
- Core::Obj
- Gloo::Objs::String
- Defined in:
- lib/gloo/objs/basic/string.rb
Constant Summary collapse
- KEYWORD =
'string'.freeze
- KEYWORD_SHORT =
'str'.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_decode64 ⇒ Object
Decode the string from base64.
-
#msg_down ⇒ Object
Convert string to lower case.
-
#msg_encode64 ⇒ Object
Encode the string as base64.
-
#msg_escape ⇒ Object
Escape the string.
-
#msg_gen_alphanumeric ⇒ Object
Generate a random alphanumeric string.
-
#msg_gen_base64 ⇒ Object
Generate a random base64 string.
-
#msg_gen_hex ⇒ Object
Generate a random hex string.
-
#msg_gen_uuid ⇒ Object
Generate a new UUID in the string.
-
#msg_size ⇒ Object
Get the size of the string.
-
#msg_unescape ⇒ Object
Unescape the string.
-
#msg_up ⇒ Object
Convert string to upper case.
-
#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_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
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.
44 45 46 47 |
# File 'lib/gloo/objs/basic/string.rb', line 44 def self. return super + %w[up down size encode64 decode64 escape unescape gen_alphanumeric gen_uuid gen_hex gen_base64] end |
.short_typename ⇒ Object
The short name of the object type.
26 27 28 |
# File 'lib/gloo/objs/basic/string.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/string.rb', line 19 def self.typename return KEYWORD end |
Instance Method Details
#msg_decode64 ⇒ Object
Decode the string from base64. Changes the value of the string.
96 97 98 99 100 101 |
# File 'lib/gloo/objs/basic/string.rb', line 96 def msg_decode64 s = Base64.decode64( value ) set_value s @engine.heap.it.set_to s return s end |
#msg_down ⇒ Object
Convert string to lower case
183 184 185 186 187 188 |
# File 'lib/gloo/objs/basic/string.rb', line 183 def msg_down s = value.downcase set_value s @engine.heap.it.set_to s return s end |
#msg_encode64 ⇒ Object
Encode the string as base64. Changes the value of the string.
85 86 87 88 89 90 |
# File 'lib/gloo/objs/basic/string.rb', line 85 def msg_encode64 s = Base64.encode64( value ) set_value s @engine.heap.it.set_to s return s end |
#msg_escape ⇒ Object
Escape the string. Make it URL safe. The value of the string is changed.
63 64 65 66 67 68 |
# File 'lib/gloo/objs/basic/string.rb', line 63 def msg_escape s = URI::DEFAULT_PARSER.escape( value ) set_value s @engine.heap.it.set_to s return s end |
#msg_gen_alphanumeric ⇒ Object
Generate a random alphanumeric string. By default the length is 10 characters. Set the length with an optional parameter.
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/gloo/objs/basic/string.rb', line 118 def msg_gen_alphanumeric len = 10 if @params&.token_count&.positive? expr = Gloo::Expr::Expression.new( @engine, @params.tokens ) data = expr.evaluate len = data.to_i end s = StringGenerator.alphanumeric( len ) set_value s @engine.heap.it.set_to s return s end |
#msg_gen_base64 ⇒ Object
Generate a random base64 string. By default the length is 12 characters. Set the length with an optional parameter.
156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/gloo/objs/basic/string.rb', line 156 def msg_gen_base64 len = 12 if @params&.token_count&.positive? expr = Gloo::Expr::Expression.new( @engine, @params.tokens ) data = expr.evaluate len = data.to_i end s = StringGenerator.base64( len ) set_value s @engine.heap.it.set_to s return s end |
#msg_gen_hex ⇒ Object
Generate a random hex string. By default the length is 10 hex characters. Set the length with an optional parameter.
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/gloo/objs/basic/string.rb', line 137 def msg_gen_hex len = 10 if @params&.token_count&.positive? expr = Gloo::Expr::Expression.new( @engine, @params.tokens ) data = expr.evaluate len = data.to_i end s = StringGenerator.hex( len ) set_value s @engine.heap.it.set_to s return s end |
#msg_gen_uuid ⇒ Object
Generate a new UUID in the string.
106 107 108 109 110 111 |
# File 'lib/gloo/objs/basic/string.rb', line 106 def msg_gen_uuid s = StringGenerator.uuid set_value s @engine.heap.it.set_to s return s end |
#msg_size ⇒ Object
Get the size of the string.
52 53 54 55 56 |
# File 'lib/gloo/objs/basic/string.rb', line 52 def msg_size s = value.size @engine.heap.it.set_to s return s end |
#msg_unescape ⇒ Object
Unescape the string. The value of the string is changed.
74 75 76 77 78 79 |
# File 'lib/gloo/objs/basic/string.rb', line 74 def msg_unescape s = URI::DEFAULT_PARSER.unescape( value ) set_value s @engine.heap.it.set_to s return s end |
#msg_up ⇒ Object
Convert string to upper case
173 174 175 176 177 178 |
# File 'lib/gloo/objs/basic/string.rb', line 173 def msg_up s = value.upcase set_value s @engine.heap.it.set_to s return s end |
#set_value(new_value) ⇒ Object
Set the value with any necessary type conversions.
33 34 35 |
# File 'lib/gloo/objs/basic/string.rb', line 33 def set_value( new_value ) self.value = new_value.to_s end |