Class: RBS::Trace::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/trace/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass:, name:, lineno:) ⇒ Definition

Returns a new instance of Definition.



11
12
13
14
15
# File 'lib/rbs/trace/definition.rb', line 11

def initialize(klass:, name:, lineno:)
  @klass = klass
  @name = name
  @lineno = lineno
end

Instance Attribute Details

#klassObject (readonly)

: Class



6
7
8
# File 'lib/rbs/trace/definition.rb', line 6

def klass
  @klass
end

#linenoObject (readonly)

: Integer



8
9
10
# File 'lib/rbs/trace/definition.rb', line 8

def lineno
  @lineno
end

#nameObject (readonly)

: Symbol



7
8
9
# File 'lib/rbs/trace/definition.rb', line 7

def name
  @name
end

Instance Method Details

#declsObject



18
19
20
# File 'lib/rbs/trace/definition.rb', line 18

def decls
  @decls ||= []
end

#rbsObject



28
29
30
# File 'lib/rbs/trace/definition.rb', line 28

def rbs
  @decls.inject { |result, decl| result.merge(decl) }.to_rbs
end

#rbs_comment(indent = 0) ⇒ Object



23
24
25
# File 'lib/rbs/trace/definition.rb', line 23

def rbs_comment(indent = 0)
  "#{" " * indent}# @rbs #{rbs}\n"
end