Class: Spektr::Exp::Definition

Inherits:
Base
  • Object
show all
Defined in:
lib/spektr/exp/definition.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#arguments, #ast, #body, #location, #name, #options, #type

Instance Method Summary collapse

Methods inherited from Base

#handler_missing, #send?

Constructor Details

#initialize(ast) ⇒ Definition

Returns a new instance of Definition.



6
7
8
9
# File 'lib/spektr/exp/definition.rb', line 6

def initialize(ast)
  super
  process @ast.children
end

Instance Attribute Details

#privateObject

Returns the value of attribute private.



4
5
6
# File 'lib/spektr/exp/definition.rb', line 4

def private
  @private
end

#protectedObject

Returns the value of attribute protected.



4
5
6
# File 'lib/spektr/exp/definition.rb', line 4

def protected
  @protected
end

Instance Method Details

#process(ast) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/spektr/exp/definition.rb', line 11

def process(ast)
  ast&.each do |node|
    next unless Parser::AST::Node === node
    case node.type
    when :args
      node.children.each do |argument|
        @arguments << argument.children.first
      end
    when :begin
      process(node.children)
    when :lvasgn
      @body << Lvasign.new(node)
    when :ivasgn
      @body << Ivasign.new(node)
    when :send
      @body << Send.new(node)
    end
  end
end