Class: Y2R::AST::Ruby::MethodCall
- Inherits:
-
Node
- Object
- OpenStruct
- Node
- Y2R::AST::Ruby::MethodCall
show all
- Defined in:
- lib/y2r/ast/ruby.rb
Constant Summary
Constants inherited
from Node
Node::INDENT_STEP
Instance Method Summary
collapse
Methods inherited from Node
#ensure_separated, #has_comment?, #hates_to_stand_alone?, #single_line_width, #to_ruby
Instance Method Details
1213
1214
1215
1216
1217
1218
1219
|
# File 'lib/y2r/ast/ruby.rb', line 1213
def
if parens
|| (block && block.)
else
end
end
|
#pass_trailer? ⇒ Boolean
1221
1222
1223
1224
1225
1226
1227
|
# File 'lib/y2r/ast/ruby.rb', line 1221
def pass_trailer?
if parens
block
else
false
end
end
|
#priority ⇒ Object
1201
1202
1203
|
# File 'lib/y2r/ast/ruby.rb', line 1201
def priority
parens ? Priority::ATOMIC : Priority::NONE
end
|
#single_line_width_base(context) ⇒ Object
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
|
# File 'lib/y2r/ast/ruby.rb', line 1183
def single_line_width_base(context)
if ! && !
receiver_context = context.with_priority(Priority::ATOMIC)
receiver_width = if receiver
receiver.single_line_width(receiver_context) + 1
else
0
end
args_context = context.with_priority(Priority::NONE)
args_width = args_single_line_width(args_context)
receiver_width + name.size + args_width
else
Float::INFINITY
end
end
|
1205
1206
1207
1208
1209
1210
1211
|
# File 'lib/y2r/ast/ruby.rb', line 1205
def
if parens
|| (receiver && receiver.)
else
end
end
|
#to_ruby_base(context) ⇒ Object
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
# File 'lib/y2r/ast/ruby.rb', line 1140
def to_ruby_base(context)
receiver_context = context.with_trailer(".").with_priority(Priority::ATOMIC)
receiver_code = receiver ? "#{receiver.to_ruby(receiver_context)}" : ""
if
context = context.indented(INDENT_STEP)
end
args_shift = receiver_code.size + name.size
args_context = context.
shifted(args_shift).
without_trailer.
with_priority(Priority::NONE)
args_code = emit_args(context, args_context)
if Code.multi_line?(args_code)
block_context = context.shifted(1).with_priority(Priority::NONE)
else
block_shift = args_shift + args_code.size
block_context = context.
shifted(block_shift).
with_priority(Priority::NONE)
end
block_code = block ? " #{block.to_ruby(block_context)}" : ""
if !
"#{receiver_code}#{name}#{args_code}#{block_code}"
else
combine do |parts|
parts << receiver_code
parts << indent("#{name}#{args_code}#{block_code}")
end
end
end
|