さて、意図を明確にするための提案に従って、私は質問を言い直しました。この例が明確であることを願っています。
$funcname = ""
$message = ""
$DebugFormat = "Within #{$funcname} message: #{$message}"
def Something
$funcname = "Something"
# .
# .
# .
$message = "an important message."
puts "#{$DebugFormat}"
end
def Another
$funcname = "Another"
# Another method related code ...
$message = "Result message to output"
puts "#{$DebugFormat}"
end
したがって、同じフォーマットなどを繰り返す必要なく、さまざまな場所で使用できるさまざまなデバッグ関連の文字列を用意するという考え方です。
とにかく、これはそれほど重要ではなく、Ruby をよりよく学ぼうとする試みにすぎません。
気楽に行き、
-ダニエル