Kenji Okimoto
okimo****@clear*****
Fri Oct 11 11:11:35 JST 2013
> + def to_s > + "Total requests: #{total_n_requests} " + > + "(#{queries_per_second} queries per second)\n" + > + "Status:\n" + > + status_percentages.collect do |status, percentage| > + " #{status}: #{percentage} %" > + end.join("\n") + "\n" + > + "Elapsed time:\n" + > + " min: #{min_elapsed_time} sec\n" + > + " max: #{max_elapsed_time} sec\n" + > + " average: #{average_elapsed_time} sec" > + end ヒアドキュメント使わないのは何か理由がありますか? ここまで複雑ならヒアドキュメントを使った方がすっきりするように思いました。 例えば、動かしてませんが、以下のような感じでしょうか。 "\n" とか + とか が減ってすっきりしていると思います。 def to_s _status = status_percentages.collect do |status, percentage| " #{status}: #{percentage} %" end.join("\n") <<-EOS.chomp Total requests: #{total_n_requests} (#{queries_per_second} queries per second) Status: #{_status} Elapsed time: min: #{min_elapsed_time} sec max: #{max_elapsed_time} sec average: #{average_elapsed_time} sec EOS end On 2013年10月11日 10:23, YUKI Hiroshi wrote: > Author > YUKI Hiroshi <shimoda �� clear-code.com> > Date > 2013-10-11 10:23:44 +0900 (Fri, 11 Oct 2013) > New Revision > bbb317346cf5d393afb3cf952c3daae62084a43d <https://github.com/droonga/drnbench/commit/bbb317346cf5d393afb3cf952c3daae62084a43d> > Message > > Separate definition of client and result classes from runner.rb > > Added files > > * lib/droonga/benchmark/client/http.rb <https://github.com/droonga/drnbench/commit/bbb317346cf5d393afb3cf952c3daae62084a43d#diff-0> > * lib/droonga/benchmark/result.rb <https://github.com/droonga/drnbench/commit/bbb317346cf5d393afb3cf952c3daae62084a43d#diff-1> > > Modified files > > * lib/droonga/benchmark/runner.rb <https://github.com/droonga/drnbench/commit/bbb317346cf5d393afb3cf952c3daae62084a43d#diff-2> > > Added: lib/droonga/benchmark/client/http.rb (+69 -0) 100644 > =================================================================== > -- Kenji Okimoto <okimoto �� clear-code.com>