Class: Spoom::RBS::Comments

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComments

: -> void



14
15
16
17
# File 'lib/spoom/rbs.rb', line 14

def initialize
  @annotations = [] #: Array[Annotation]
  @signatures = [] #: Array[Signature]
end

Instance Attribute Details

#annotationsObject (readonly)

: Array



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

def annotations
  @annotations
end

#signaturesObject (readonly)

: Array



11
12
13
# File 'lib/spoom/rbs.rb', line 11

def signatures
  @signatures
end

Instance Method Details

#class_annotationsObject

: -> Array



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/spoom/rbs.rb', line 25

def class_annotations
  @annotations.select do |annotation|
    case annotation.string
    when "@abstract", "@interface", "@sealed", "@final"
      true
    when /^@requires_ancestor: /
      true
    else
      false
    end
  end
end

#empty?Boolean

: -> bool

Returns:

  • (Boolean)


20
21
22
# File 'lib/spoom/rbs.rb', line 20

def empty?
  @annotations.empty? && @signatures.empty?
end

#method_annotationsObject

: -> Array



39
40
41
42
43
44
45
46
47
48
# File 'lib/spoom/rbs.rb', line 39

def method_annotations
  @annotations.select do |annotation|
    case annotation.string
    when "@abstract", "@final", "@override", "@override(allow_incompatible: true)", "@overridable", "@without_runtime"
      true
    else
      false
    end
  end
end