Class: Xumlidot::Parsers::Call
- Inherits:
-
MethodBasedSexpProcessor
- Object
- MethodBasedSexpProcessor
- Xumlidot::Parsers::Call
- Defined in:
- lib/xumlidot/parsers/call.rb
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #add_attributes(name, exp, read: false, write: false) ⇒ Object
-
#initialize(exp, klass) ⇒ Call
constructor
A new instance of Call.
-
#process_array(exp) ⇒ Object
If we have e.g a constant in the class definition which is assigned an array this prevents us having those constants defined as a parent class.
-
#process_call(exp) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength.
- #process_colon2(exp) ⇒ Object
- #process_colon3(exp) ⇒ Object
- #process_const(exp) ⇒ Object
Constructor Details
#initialize(exp, klass) ⇒ Call
Returns a new instance of Call.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xumlidot/parsers/call.rb', line 11 def initialize(exp, klass) super() @klass = klass @modules = ::Xumlidot::Types::InheritedModule.new(nil) process(exp) return if klass.definition.nil? klass.definition.inherited_modules << @modules end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
9 10 11 |
# File 'lib/xumlidot/parsers/call.rb', line 9 def definition @definition end |
Instance Method Details
#add_attributes(name, exp, read: false, write: false) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/xumlidot/parsers/call.rb', line 84 def add_attributes(name, exp, read: false, write: false) @klass.attributes << ::Xumlidot::Types::Attribute.new(name.value, read, write) exp.each do |attribute| @klass.attributes << ::Xumlidot::Types::Attribute.new(attribute.value, read, write) end end |
#process_array(exp) ⇒ Object
If we have e.g a constant in the class definition which is assigned an array this prevents us having those constants defined as a parent class. See issue #30
76 77 78 79 80 81 82 |
# File 'lib/xumlidot/parsers/call.rb', line 76 def process_array(exp) exp.shift # remove :array exp.each do |element| process_until_empty(element) end s() end |
#process_call(exp) ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/xumlidot/parsers/call.rb', line 26 def process_call(exp) _call = exp.shift # remove the :call begin shifted = exp.shift _recv = process(shifted) rescue StandardError => _e # Reaching here when the shifted value is an array, hash, or iter # one example: # BaseMailer.view_paths = [File.join(FIXTURE_LOAD_PATH, "another.path")] + old.dup warn " ** bug: unable to calculate reciever for #{exp}" end name = exp.shift args = exp.shift case name when :private, :public, :protected ::Xumlidot::Parsers::Scope.set_visibility(name) when :include @modules.type = :include process(args) when :extend @modules.type = :extend process(args) when :prepend @modules.type = :prepend process(args) # when :module_function # TODO: expose as an instance method on the module # when :public_constant # TODO: when :attr_reader add_attributes(args, exp, read: true) when :attr_writer add_attributes(args, exp, write: true) when :attr_accessor add_attributes(args, exp, read: true, write: true) # else # warn "CALL RECV:#{recv unless recv.nil? || recv.empty?} " \ # "NAME:#{name} ARGS:#{args unless args.nil? || args.empty?}" end s() end |
#process_colon2(exp) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/xumlidot/parsers/call.rb', line 99 def process_colon2(exp) exp.shift # remove :colon2 @modules << exp.value process_until_empty(exp) s() end |
#process_colon3(exp) ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/xumlidot/parsers/call.rb', line 106 def process_colon3(exp) exp.shift # remove :colon3 @modules << '::' @modules << exp.value process_until_empty(exp) s() end |
#process_const(exp) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/xumlidot/parsers/call.rb', line 92 def process_const(exp) # exp.shift # remove :const @modules << exp.value process_until_empty(exp) s() end |