Class: Rucoa::Definitions::MethodDefinition
- Defined in:
- lib/rucoa/definitions/method_definition.rb
Instance Attribute Summary collapse
- #kind ⇒ Symbol readonly
- #method_name ⇒ String readonly
- #namespace ⇒ String readonly
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(kind:, method_name:, namespace:, types:, **keyword_arguments) ⇒ MethodDefinition
constructor
A new instance of MethodDefinition.
- #instance_method? ⇒ Boolean
- #parameters ⇒ Array<Rucoa::Definitions::MethodParameter>
- #qualified_name ⇒ String
- #return_types ⇒ Array<String>
- #signatures ⇒ Array<String>
- #singleton_method? ⇒ Boolean
Constructor Details
#initialize(kind:, method_name:, namespace:, types:, **keyword_arguments) ⇒ MethodDefinition
Returns a new instance of MethodDefinition.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rucoa/definitions/method_definition.rb', line 19 def initialize( kind:, method_name:, namespace:, types:, **keyword_arguments ) super(**keyword_arguments) @kind = kind @method_name = method_name @namespace = namespace @types = types end |
Instance Attribute Details
#kind ⇒ Symbol (readonly)
7 8 9 |
# File 'lib/rucoa/definitions/method_definition.rb', line 7 def kind @kind end |
#method_name ⇒ String (readonly)
10 11 12 |
# File 'lib/rucoa/definitions/method_definition.rb', line 10 def method_name @method_name end |
#namespace ⇒ String (readonly)
13 14 15 |
# File 'lib/rucoa/definitions/method_definition.rb', line 13 def namespace @namespace end |
Instance Method Details
#instance_method? ⇒ Boolean
34 35 36 |
# File 'lib/rucoa/definitions/method_definition.rb', line 34 def instance_method? @kind == :instance end |
#parameters ⇒ Array<Rucoa::Definitions::MethodParameter>
TODO:
40 41 42 |
# File 'lib/rucoa/definitions/method_definition.rb', line 40 def parameters [] end |
#qualified_name ⇒ String
58 59 60 61 62 63 64 |
# File 'lib/rucoa/definitions/method_definition.rb', line 58 def qualified_name [ @namespace, method_kind_symbol, @method_name ].join end |
#return_types ⇒ Array<String>
81 82 83 |
# File 'lib/rucoa/definitions/method_definition.rb', line 81 def return_types @types.map(&:return_type) end |
#signatures ⇒ Array<String>
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rucoa/definitions/method_definition.rb', line 102 def signatures @types.map do |type| format( '%<qualified_name>s(%<parameters>s) -> %<return_types>s', parameters: type.parameters_string, qualified_name: qualified_name, return_types: type.return_type ) end end |
#singleton_method? ⇒ Boolean
114 115 116 |
# File 'lib/rucoa/definitions/method_definition.rb', line 114 def singleton_method? !instance_method? end |