Class: Zapata::Primitive::Klass
- Defined in:
- lib/zapata/primitive/klass.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(code) ⇒ Klass
constructor
A new instance of Klass.
- #node ⇒ Object
- #parent_modul_names ⇒ Object
Methods inherited from Base
#dive_deeper, #name, #return_with_missing_as_super, #return_with_super_as_missing, #to_raw
Constructor Details
#initialize(code) ⇒ Klass
Returns a new instance of Klass.
6 7 8 9 10 11 12 13 |
# File 'lib/zapata/primitive/klass.rb', line 6 def initialize(code) @code = code @moduls = Diver.current_moduls.dup Diver.access_level = :public Diver.current_klass = self dive_deeper Diver.current_klass = nil end |
Instance Method Details
#node ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/zapata/primitive/klass.rb', line 19 def node const, _, body = @code.to_a immediate_modul, klass = const.to_a chain = parent_modul_names + [immediate_modul, klass] name = chain.compact.join('::') type = @code.type OpenStruct.new( type: type, immediate_modul: immediate_modul, klass: klass, name: name, body: body ) end |
#parent_modul_names ⇒ Object
15 16 17 |
# File 'lib/zapata/primitive/klass.rb', line 15 def parent_modul_names @moduls.map { |mod| mod&.name }.compact end |