Class: RubyLint::DefinitionBuilder::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-lint/definition_builder/base.rb

Overview

Base definition builder that provides common methods for individual builder classes.

Direct Known Subclasses

Primitive, RubyArray, RubyBlock, RubyMethod, RubyModule

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, vm, options = {}) ⇒ Base

Returns a new instance of Base

Parameters:



21
22
23
24
25
26
27
# File 'lib/ruby-lint/definition_builder/base.rb', line 21

def initialize(node, vm, options = {})
  @node    = node
  @vm      = vm
  @options = options

  after_initialize if respond_to?(:after_initialize)
end

Instance Attribute Details

#nodeRubyLint::AST::Node (readonly)

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby-lint/definition_builder/base.rb', line 13

class Base
  attr_reader :vm, :node, :options

  ##
  # @param [RubyLint::AST::Node] node
  # @param [RubyLint::VirtualMachine] vm
  # @param [Hash] options
  #
  def initialize(node, vm, options = {})
    @node    = node
    @vm      = vm
    @options = options

    after_initialize if respond_to?(:after_initialize)
  end

  protected

  ##
  # Returns the name of a constant node as a String.
  #
  # @param [RubyLint::AST::Node] node
  # @return [String]
  #
  def constant_name(node)
    return node.children[1].to_s
  end
end

#optionsObject (readonly)

Returns the value of attribute options



14
15
16
# File 'lib/ruby-lint/definition_builder/base.rb', line 14

def options
  @options
end

#vmRubyLint::VirtualMachine (readonly)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ruby-lint/definition_builder/base.rb', line 13

class Base
  attr_reader :vm, :node, :options

  ##
  # @param [RubyLint::AST::Node] node
  # @param [RubyLint::VirtualMachine] vm
  # @param [Hash] options
  #
  def initialize(node, vm, options = {})
    @node    = node
    @vm      = vm
    @options = options

    after_initialize if respond_to?(:after_initialize)
  end

  protected

  ##
  # Returns the name of a constant node as a String.
  #
  # @param [RubyLint::AST::Node] node
  # @return [String]
  #
  def constant_name(node)
    return node.children[1].to_s
  end
end

Instance Method Details

#constant_name(node) ⇒ String (protected)

Returns the name of a constant node as a String.

Parameters:

Returns:



37
38
39
# File 'lib/ruby-lint/definition_builder/base.rb', line 37

def constant_name(node)
  return node.children[1].to_s
end