Class: MethodEntity

Inherits:
Entity show all
Defined in:
lib/exploration/method_entity.rb

Instance Attribute Summary

Attributes inherited from Explorer

#resolve_strategy

Instance Method Summary collapse

Methods inherited from Entity

#add_explorer, #initialize

Constructor Details

This class inherits a constructor from Entity

Instance Method Details

#each(sexp, context = nil, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/exploration/method_entity.rb', line 5

def each sexp, context=nil, &block
  # NOTE does not handle file with only methods in it
  sexp.each_sexp do |sub_sexp|
    if [:defn, :defs].include? sub_sexp.sexp_type
      # TODO handle arguments for methods
      if sub_sexp.rest.first.kind_of? Sexp # TODO right now, we assume this is self, need to look into
        name = sub_sexp.rest.rest.first.to_s
      else
        name = sub_sexp.rest.first.to_s
      end
      block.call context, :defines, { name: name, type: :method }
      explore sub_sexp, context, &block
    end
  end
end