Class: Zapata::Primitive::Def

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

Instance Attribute Summary collapse

Attributes inherited from Base

#code, #type

Instance Method Summary collapse

Methods inherited from Base

#dive_deeper, #name, #return_with_missing_as_super, #return_with_super_as_missing, #to_raw

Constructor Details

#initialize(code) ⇒ Def

Returns a new instance of Def.



8
9
10
11
12
13
14
# File 'lib/zapata/primitive/def.rb', line 8

def initialize(code)
  @code = code
  @klass = Diver.current_klass
  @self = Diver.current_sklass
  @access_level = Diver.access_level
  dive_deeper
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



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

def klass
  @klass
end

Instance Method Details

#literal_predicted_argsObject



30
31
32
# File 'lib/zapata/primitive/def.rb', line 30

def literal_predicted_args
  Predictor::Args.literal(node.args)
end

#nodeObject



24
25
26
27
28
# File 'lib/zapata/primitive/def.rb', line 24

def node
  name, args, body = @code.to_a
  type = @code.type
  OpenStruct.new(type: type, name: name, args: args, body: body)
end

#public?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/zapata/primitive/def.rb', line 20

def public?
  @access_level == :public
end

#self?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/zapata/primitive/def.rb', line 16

def self?
  !!@self
end