Class: DissociatedIntrospection::RubyClass::CreateDef

Inherits:
Object
  • Object
show all
Defined in:
lib/dissociated_introspection/ruby_class/create_def.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ast, comments) ⇒ CreateDef

Returns a new instance of CreateDef.



6
7
8
9
# File 'lib/dissociated_introspection/ruby_class/create_def.rb', line 6

def initialize(ast, comments)
  @ast      = ast
  @comments = comments
end

Instance Attribute Details

#astObject (readonly)

Returns the value of attribute ast.



4
5
6
# File 'lib/dissociated_introspection/ruby_class/create_def.rb', line 4

def ast
  @ast
end

#commentsObject (readonly)

Returns the value of attribute comments.



4
5
6
# File 'lib/dissociated_introspection/ruby_class/create_def.rb', line 4

def comments
  @comments
end

Instance Method Details

#createObject



11
12
13
14
15
16
# File 'lib/dissociated_introspection/ruby_class/create_def.rb', line 11

def create
  def_comments = comments.select do |comment|
    comment.location.last_line + 1 == ast.location.first_line
  end
  Def.new(RubyCode.build_from_ast(ast, comments: def_comments))
end