Class: XfOOrth::AbstractWordSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/fOOrth/compiler/word_specs.rb,
lib/fOOrth/library/introspection/word_specs.rb

Overview

Get information about this word spec.

Instance Attribute Summary collapse

Instance Method Summary collapse

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, tags, &block)
  @tags = tags
  @does = block || get_stub_action(name, symbol)
  build_builds_string(name, symbol)
end

Instance Attribute Details

#buildsObject (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

#doesObject (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

#tagsObject (readonly)

The attributes tagged to this specification.



17
18
19
# File 'lib/fOOrth/compiler/word_specs.rb', line 17

def tags
  @tags
end

Instance Method Details

#get_infoObject

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"  , 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.

Returns:

  • (Boolean)


47
48
49
# File 'lib/fOOrth/compiler/word_specs.rb', line 47

def has_tag?(tag)
  @tags.include?(tag)
end