class RubyLint::DefinitionBuilder::RubyModule
Definition
builder used for building Ruby modules as well as providing the groundwork for building Ruby classes.
Public Instance Methods
build()
click to toggle source
Creates a new module definition.
@see new_definition
# File lib/ruby-lint/definition_builder/ruby_module.rb, line 13 def build mod = vm.global_constant('Module') return new_definition([mod, vm.current_scope]) end
scope()
click to toggle source
Determines the scope to define the module in.
@return [RubyLint::Definition::RubyObject]
# File lib/ruby-lint/definition_builder/ruby_module.rb, line 24 def scope scope = vm.current_scope name_prefix = node.children[0].children[0] # name_prefix contains the constant path leading up to the name. For # example, if the name is `A::B::C` this node would contain `A::B`. if name_prefix found = ConstantPath.new(name_prefix).resolve(vm.current_scope) scope = found if found end return scope end
Protected Instance Methods
module_name()
click to toggle source
Returns the name of the module.
@see constant_name
# File lib/ruby-lint/definition_builder/ruby_module.rb, line 45 def module_name return constant_name(node.children[0]) end
new_definition(parents)
click to toggle source
Creates a new RubyObject definition with the specified parent definitions.
@param [Array] parents @return [RubyLint::Definition::RubyObject]
# File lib/ruby-lint/definition_builder/ruby_module.rb, line 56 def new_definition(parents) definition = Definition::RubyObject.new( :name => module_name, :parents => parents, :reference_amount => 1, :type => :const, :line => node.line, :column => node.column, :file => node.file ) definition.define_self return definition end