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.



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

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.



4
5
6
# File 'lib/zapata/primitive/def.rb', line 4

def klass
  @klass
end

Instance Method Details

#literal_predicted_argsObject



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

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

#nodeObject



22
23
24
25
26
# File 'lib/zapata/primitive/def.rb', line 22

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)


18
19
20
# File 'lib/zapata/primitive/def.rb', line 18

def public?
  @access_level == :public
end

#self?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/zapata/primitive/def.rb', line 14

def self?
  !!@self
end