Class: XfOOrth::AbstractWordSpec
- Defined in:
- lib/fOOrth/compiler/word_specs.rb,
lib/fOOrth/library/introspection/word_specs.rb
Overview
Get information about this word spec.
Direct Known Subclasses
ClassSpec, GlobalVarSpec, InstanceVarSpec, LocalSpec, MacroSpec, NosSpec, SelfSpec, ThreadVarSpec, TosSpec, VmSpec
Instance Attribute Summary collapse
-
#builds ⇒ Object
readonly
The compile-time text inserted into the buffer.
-
#does ⇒ Object
readonly
The run-time action; The block that gets linked to the method’s symbol.
-
#tags ⇒ Object
readonly
The attributes tagged to this specification.
Instance Method Summary collapse
-
#get_info ⇒ Object
Get introspection info.
-
#get_stub_action(name, symbol) ⇒ Object
Get the default action if none is specified.
-
#has_tag?(tag) ⇒ Boolean
Look up a tag of interest.
-
#initialize(name, symbol, tags, &block) ⇒ AbstractWordSpec
constructor
Set up the method spec.
Constructor Details
#initialize(name, symbol, tags, &block) ⇒ AbstractWordSpec
Set up the method spec.
Parameters:
-
name - The string that maps to the symbol.
-
symbol - The symbol that the name maps to.
-
tags - A an array of tags.
These include:
-
:class - This spec defines a class.
-
:immediate - The word is executed, even in compile modes.
-
:macro - This spec defines an in-line macro.
-
:stub - The word is a place holder in the hierarchy.
-
:temp - A temporary spec used during compilation.
-
none - Nothing special here. Move along, move along.
Endemic Code Smells
-
:reek:ControlParameter – false positive
33 34 35 36 37 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 33 def initialize(name, symbol, , &block) @tags = @does = block || get_stub_action(name, symbol) build_builds_string(name, symbol) end |
Instance Attribute Details
#builds ⇒ Object (readonly)
The compile-time text inserted into the buffer.
11 12 13 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 11 def builds @builds end |
#does ⇒ Object (readonly)
The run-time action; The block that gets linked to the method’s symbol.
14 15 16 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 14 def does @does end |
#tags ⇒ Object (readonly)
The attributes tagged to this specification.
17 18 19 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 17 def @tags end |
Instance Method Details
#get_info ⇒ Object
Get introspection info.
10 11 12 13 14 15 |
# File 'lib/fOOrth/library/introspection/word_specs.rb', line 10 def get_info [["Spec" , self.class.foorth_name], ["Tags" , .join(' ')], ["Builds", builds], ["Does" , does.inspect]] end |
#get_stub_action(name, symbol) ⇒ Object
Get the default action if none is specified.
40 41 42 43 44 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 40 def get_stub_action(name, symbol) lambda do |*_any| f20_error(self, name, symbol) end end |
#has_tag?(tag) ⇒ Boolean
Look up a tag of interest.
47 48 49 |
# File 'lib/fOOrth/compiler/word_specs.rb', line 47 def has_tag?(tag) @tags.include?(tag) end |