Class: Renderer::Component::MethodArgument
Constant Summary
collapse
- REST_ARG_BY_TYPE =
{
kwrest: :double,
rest: :single,
block: :block
}.freeze
Instance Attribute Summary
#id
Instance Method Summary
collapse
#initialize, prop, #props, #render, #template
Instance Method Details
#continuation_for_type ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/renderer/component/method_argument.rb', line 22
def continuation_for_type
if arg.keyword? && !arg.rest?
:colon
elsif arg.optional?
:equal
end
end
|
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/renderer/component/method_argument.rb', line 8
def prepare
@type = @arg.kind
@name = @arg.name
@value = @arg.value&.source
@value_type = @arg.value_type
@computed = {
rest: rest_arg,
name:,
continuation: continuation_for_type,
value: value_for_argument
}
end
|
36
37
38
|
# File 'lib/renderer/component/method_argument.rb', line 36
def rest_arg
REST_ARG_BY_TYPE[type]
end
|
#value_for_argument ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/renderer/component/method_argument.rb', line 40
def value_for_argument
return if value_type.nil?
case value_type
when :symbol, :bool
{ kind: :symbol, value: }
when :nil
{ kind: :symbol, value: "nil" }
when :number
{ kind: :number, value: }
when :string
{ kind: :string, value: }
when :call
{ kind: :call, value: }
when :const
{ kind: :const, value: [value] }
else
{ kind: :plain, value: }
end
end
|