lib/yard/templates/helpers/method_helper.rb in yard-0.9.27 vs lib/yard/templates/helpers/method_helper.rb in yard-0.9.28
- old
+ new
@@ -64,10 +64,12 @@
end.join("\n")
end
# @return [String] formats source code of a constant value
def format_constant(value)
- sp = value.split("\n").last[/^(\s+)/, 1]
+ # last can return nil, so default to empty string
+ sp = value.split("\n").last || ""
+ sp = sp[/^(\s+)/, 1]
num = sp ? sp.size : 0
html_syntax_highlight value.gsub(/^\s{#{num}}/, '')
end
end
end