Class: Xumlidot::Parsers::ModuleDefinition
- Inherits:
-
MethodBasedSexpProcessor
- Object
- MethodBasedSexpProcessor
- Xumlidot::Parsers::ModuleDefinition
- Defined in:
- lib/xumlidot/parsers/module_definition.rb
Overview
Parser for the KLASS DEFINITION ONLY and the name probably should be changed to reflect that
The main parser will handle method, constants, etc
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
-
#initialize(exp, namespace = nil) ⇒ ModuleDefinition
constructor
A new instance of ModuleDefinition.
-
#process_module(exp) ⇒ Object
rubocop:disable Metrics/AbcSize.
Constructor Details
#initialize(exp, namespace = nil) ⇒ ModuleDefinition
Returns a new instance of ModuleDefinition.
16 17 18 19 20 21 22 23 |
# File 'lib/xumlidot/parsers/module_definition.rb', line 16 def initialize(exp, namespace = nil) super() @definition = ::Xumlidot::Types::ModuleDefinition.new @namespace = namespace.dup process(exp) end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
14 15 16 |
# File 'lib/xumlidot/parsers/module_definition.rb', line 14 def definition @definition end |
Instance Method Details
#process_module(exp) ⇒ Object
rubocop:disable Metrics/AbcSize
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 |
# File 'lib/xumlidot/parsers/module_definition.rb', line 26 def process_module(exp) exp.shift # remove :module definition = exp.shift # Processes the name of the module if Sexp === definition # rubocop:disable Style/CaseEquality case definition.sexp_type when :colon2 # Reached in the event that a name is a compound name = definition.flatten name.delete :const name.delete :colon2 name.each do |v| @definition.name << ::Xumlidot::Types::Constant.new(v, @namespace) end when :colon3 # Reached in the event that a name begins with :: @definition.name << ::Xumlidot::Types::Constant.new(definition.last, '::') else raise "unknown type #{exp.inspect}" end # FIXME: bug - fix when we've added specs else # Symbol === definition # if we have a symbol we have the actual module name e.g. module Foo; end @definition.name << ::Xumlidot::Types::Constant.new(definition, @namespace) end s() end |