Class: Zapata::Primitive::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/zapata/primitive/base.rb

Direct Known Subclasses

Arg, Array, Basic, Casgn, Def, Defs, Hash, Klass, Lvar, Modul, Optarg, Send, Sklass, Var

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/zapata/primitive/base.rb', line 8

def initialize(code)
  @code = code
  @type = code.type
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



6
7
8
# File 'lib/zapata/primitive/base.rb', line 6

def code
  @code
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/zapata/primitive/base.rb', line 6

def type
  @type
end

Instance Method Details

#dive_deeperObject



17
18
19
20
21
22
# File 'lib/zapata/primitive/base.rb', line 17

def dive_deeper
  return if RETURN_TYPES.include?(node.type)

  Diver.dive(node.args)
  Diver.dive(node.body)
end

#nameObject



13
14
15
# File 'lib/zapata/primitive/base.rb', line 13

def name
  SaveManager.clean(node.name)
end

#return_with_missing_as_super(raw, name) ⇒ Object



32
33
34
# File 'lib/zapata/primitive/base.rb', line 32

def return_with_missing_as_super(raw, name)
  raw.type == :missing ? Raw.new(:super, name) : raw
end

#return_with_super_as_missing(raw, primitive) ⇒ Object



28
29
30
# File 'lib/zapata/primitive/base.rb', line 28

def return_with_super_as_missing(raw, primitive)
  raw.type == :super ? Missing.new(primitive.name).to_raw : raw
end

#to_rawObject



24
25
26
# File 'lib/zapata/primitive/base.rb', line 24

def to_raw
  Diver.dive(node.body).to_raw
end