Class: GlooLang::Core::Verb

Inherits:
Baseo
  • Object
show all
Defined in:
lib/gloo_lang/core/verb.rb

Constant Summary

Constants inherited from Baseo

Baseo::NOT_IMPLEMENTED_ERR

Instance Attribute Summary collapse

Attributes inherited from Baseo

#name

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, tokens, params = []) ⇒ Verb

Set up the verb.



19
20
21
22
23
# File 'lib/gloo_lang/core/verb.rb', line 19

def initialize( engine, tokens, params = [] )
  @engine = engine
  @tokens = tokens
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



14
15
16
# File 'lib/gloo_lang/core/verb.rb', line 14

def params
  @params
end

#tokensObject (readonly)

Returns the value of attribute tokens.



14
15
16
# File 'lib/gloo_lang/core/verb.rb', line 14

def tokens
  @tokens
end

Class Method Details

.helpObject

Get help for this verb.



81
82
83
# File 'lib/gloo_lang/core/verb.rb', line 81

def self.help
  return 'No help found.'
end

.inherited(subclass) ⇒ Object

Register verbs when they are loaded.



28
29
30
# File 'lib/gloo_lang/core/verb.rb', line 28

def self.inherited( subclass )
  Dictionary.instance.register_verb( subclass )
end

.keywordObject

Get the Verb’s keyword.

The keyword will be in lower case only. It is used by the parser.



48
49
50
# File 'lib/gloo_lang/core/verb.rb', line 48

def self.keyword
  raise 'this method should be overriden'
end

.keyword_shortcutObject

Get the Verb’s keyword shortcut.



55
56
57
# File 'lib/gloo_lang/core/verb.rb', line 55

def self.keyword_shortcut
  raise 'this method should be overriden'
end

Instance Method Details

#display_valueObject

Generic function to get display value. Can be used for debugging, etc.



70
71
72
# File 'lib/gloo_lang/core/verb.rb', line 70

def display_value
  return self.class.keyword
end

#runObject

Run the verb.

We’ll mark the application as not running and let the engine stop gracefully next time through the loop.



38
39
40
# File 'lib/gloo_lang/core/verb.rb', line 38

def run
  raise 'this method should be overriden'
end

#type_displayObject

The object type, suitable for display.



62
63
64
# File 'lib/gloo_lang/core/verb.rb', line 62

def type_display
  return self.class.keyword
end