Method: CodeExplorer::Consts#const_name_from_sexp

Defined in:
lib/code_explorer/consts.rb

#const_name_from_sexp(node) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/code_explorer/consts.rb', line 23

def const_name_from_sexp(node)
  case node.type
  when :self
    "self"
  when :cbase
    ""
  when :const, :casgn
    parent, name, _maybe_value = *node
    if parent
      const_name_from_sexp(parent) + "::#{name}"
    else
      name.to_s
    end
  else
    raise "Unexpected #{node.type}"
  end
end