Class: Gloo::Verbs::Create
- Inherits:
-
Core::Verb
- Object
- Core::Baseo
- Core::Verb
- Gloo::Verbs::Create
- Defined in:
- lib/gloo/verbs/create.rb
Constant Summary collapse
- KEYWORD =
'create'.freeze
- KEYWORD_SHORT =
'`'.freeze
- AS =
'as'.freeze
- VAL =
':'.freeze
- NO_NAME_ERR =
'Object name is missing!'.freeze
Constants inherited from Core::Baseo
Core::Baseo::NOT_IMPLEMENTED_ERR
Instance Attribute Summary
Attributes inherited from Core::Verb
Attributes inherited from Core::Baseo
Class Method Summary collapse
-
.doc_data ⇒ Object
Get the verb's documentation data.
-
.keyword ⇒ Object
Get the Verb's keyword.
-
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
Instance Method Summary collapse
-
#run ⇒ Object
Run the verb.
Methods inherited from Core::Verb
#display_value, help, inherited, #initialize, #type_display
Methods inherited from Core::Baseo
Constructor Details
This class inherits a constructor from Gloo::Core::Verb
Class Method Details
.doc_data ⇒ Object
Get the verb's documentation data.
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 113 114 115 116 117 |
# File 'lib/gloo/verbs/create.rb', line 79 def self.doc_data { :name => KEYWORD, :shortcut => KEYWORD_SHORT, :description => 'Create a new object of given type with given ' \ 'value. Both type and value are optional when creating an object.', :syntax => [ 'create {new.object.path} as {type} : {value}' ], :parameters => [ '{new.object.path} — The path and name of the new object.', '{type} — The type of the new object. Optional; if not provided the object will be untyped.', "{value} — The initial value for the new object. Optional; if not provided the object will have the default value for the type." ], :result => "If nothing exists at the path, a new object is " \ "created with the given (or type-default) value and added " \ "to the object tree, and it is set to that value. If an " \ "object already exists at the path it is left unchanged — " \ "the type and value given here are ignored — and it is set " \ "to the existing object's current value.", :errors => [ "#{NO_NAME_ERR} — The name of the object was not specified and the object cannot be created.", 'Could not create object. Bad path: {name} — The parent container named in the path does not exist. The path is root-relative and every container above the new object must already exist.' ], :examples => <<~EXAMPLES.strip # Basic examples of creating an object from the gloo shell: > create x as integer : 1 > create s : "abc" > create t # Example of creating an object with an alias: a [can] : ln [alias] : x on_load [script] : create a.ln* as string put 'test' into x show a.ln EXAMPLES } end |
.keyword ⇒ Object
Get the Verb's keyword.
35 36 37 |
# File 'lib/gloo/verbs/create.rb', line 35 def self.keyword return KEYWORD end |
.keyword_shortcut ⇒ Object
Get the Verb's keyword shortcut.
42 43 44 |
# File 'lib/gloo/verbs/create.rb', line 42 def self.keyword_shortcut return KEYWORD_SHORT end |
Instance Method Details
#run ⇒ Object
Run the verb.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gloo/verbs/create.rb', line 20 def run name = @tokens.second type = @tokens.after_token( AS ) value = @tokens.after_token( VAL ) unless name @engine.err NO_NAME_ERR return end create name, type, value end |