Class: Gelauto::MethodDef
- Inherits:
-
Object
- Object
- Gelauto::MethodDef
- Defined in:
- lib/gelauto/method_def.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nesting ⇒ Object
readonly
Returns the value of attribute nesting.
-
#return_types ⇒ Object
readonly
Returns the value of attribute return_types.
Instance Method Summary collapse
-
#initialize(name, args, nesting, return_types = TypeSet.new) ⇒ MethodDef
constructor
A new instance of MethodDef.
- #to_rbi ⇒ Object
- #to_sig ⇒ Object
Constructor Details
#initialize(name, args, nesting, return_types = TypeSet.new) ⇒ MethodDef
Returns a new instance of MethodDef.
7 8 9 10 11 12 |
# File 'lib/gelauto/method_def.rb', line 7 def initialize(name, args, nesting, return_types = TypeSet.new) @name = name @args = ArgList.new(args.map { |arg| Var.new(arg) }) @nesting = nesting @return_types = return_types end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
5 6 7 |
# File 'lib/gelauto/method_def.rb', line 5 def args @args end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/gelauto/method_def.rb', line 5 def name @name end |
#nesting ⇒ Object (readonly)
Returns the value of attribute nesting.
5 6 7 |
# File 'lib/gelauto/method_def.rb', line 5 def nesting @nesting end |
#return_types ⇒ Object (readonly)
Returns the value of attribute return_types.
5 6 7 |
# File 'lib/gelauto/method_def.rb', line 5 def return_types @return_types end |
Instance Method Details
#to_rbi ⇒ Object
30 31 32 |
# File 'lib/gelauto/method_def.rb', line 30 def to_rbi "#{to_sig}\ndef #{name}; end" end |
#to_sig ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/gelauto/method_def.rb', line 14 def to_sig components = [] unless args.empty? components << "params(#{args.to_sig})" end if name == :initialize components << 'void' else components << "returns(#{return_types.to_sig})" end "sig { #{components.join('.')} }" end |