Class: RBS::Dynamic::Builder::Methods
- Inherits:
-
Object
- Object
- RBS::Dynamic::Builder::Methods
- Defined in:
- lib/rbs/dynamic/builder/methods.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sigs ⇒ Object
readonly
Returns the value of attribute sigs.
Instance Method Summary collapse
- #<<(sig) ⇒ Object
- #build ⇒ Object
- #comment ⇒ Object
-
#initialize(name, kind: :instance) ⇒ Methods
constructor
A new instance of Methods.
- #types ⇒ Object
Constructor Details
#initialize(name, kind: :instance) ⇒ Methods
Returns a new instance of Methods.
107 108 109 110 111 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 107 def initialize(name, kind: :instance) @name = name @sigs = [] @kind = kind end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
105 106 107 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 105 def kind @kind end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
104 105 106 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 104 def name @name end |
#sigs ⇒ Object (readonly)
Returns the value of attribute sigs.
103 104 105 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 103 def sigs @sigs end |
Instance Method Details
#<<(sig) ⇒ Object
113 114 115 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 113 def <<(sig) sigs << sig end |
#build ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 117 def build RBS::AST::Members::MethodDefinition.new( name: name, kind: kind, types: types, annotations: [], location: nil, comment: comment, overload: false, visibility: sigs.last[:visibility] ) end |
#comment ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 136 def comment <<~EOS.comment if sigs.last[:source_location] && sigs.any? { _1[:reference_location] } source location: #{sigs.last[:source_location]} reference location: #{sigs.map { " #{name}#{_1.method_type} #{_1[:reference_location]}" }.uniq.join("\n")} EOS end |
#types ⇒ Object
130 131 132 133 134 |
# File 'lib/rbs/dynamic/builder/methods.rb', line 130 def types sigs.zip_sig.map { |sig| sig.method_type } end |