class RubyLint::DefinitionBuilder::RubyMethod
Definition
builder for building method definitions. Receivers should be set from the outside (= the VM).
Public Instance Methods
after_initialize()
click to toggle source
Called after a new instance has been created.
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 11 def after_initialize @options[:type] ||= :instance_method end
build()
click to toggle source
Builds the definition for the method definition.
@see new_definition
@return [RubyLint::Definition::RubyMethod]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 21 def build return new_definition([scope]) end
scope()
click to toggle source
Returns the scope to define the method in.
@return [RubyLint::Definition::RubyObject]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 30 def scope scope = vm.current_scope if has_receiver? and options[:receiver] scope = options[:receiver] end return scope end
Private Instance Methods
has_receiver?()
click to toggle source
@return [TrueClass|FalseClass]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 80 def has_receiver? return node.type == :defs end
method_name()
click to toggle source
@return [String]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 45 def method_name return node.children[name_index].to_s end
name_index()
click to toggle source
@return [Numeric]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 87 def name_index return has_receiver? ? 1 : 0 end
new_definition(parents)
click to toggle source
@param [Array] parents The parent definitions. @return [RubyLint::Definition::RubyObject]
# File lib/ruby-lint/definition_builder/ruby_method.rb, line 53 def new_definition(parents) type = options[:type] instance_type = :instance # FIXME: setting the instance type of a method to a `class` is a bit of # a hack to ensure that class methods cause lookups inside them to be # performed on class level. if has_receiver? and options[:receiver].class? type = :method instance_type = :class end return Definition::RubyMethod.new( :name => method_name, :parents => parents, :type => type, :instance_type => instance_type, :visibility => options[:visibility], :line => node.line, :column => node.column, :file => node.file ) end