[#77789] [Ruby trunk Feature#12012] Add Boolean method — prodis@...
Issue #12012 has been updated by Fernando Hamasaki de Amorim.
4 messages
2016/10/27
[ruby-core:77571] [CommonRuby Feature#12664][Assigned] Multiline pretty-printing of multiline strings
From:
shyouhei@...
Date:
2016-10-11 10:54:51 UTC
List:
ruby-core #77571
Issue #12664 has been updated by Shyouhei Urabe.
Status changed from Open to Assigned
We looked at this issue in developer meeting today and Akira was positive about this proposal. I'm assigning to him.
----------------------------------------
Feature #12664: Multiline pretty-printing of multiline strings
https://bugs.ruby-lang.org/issues/12664#change-60842
* Author: Petr Chalupa
* Status: Assigned
* Priority: Normal
* Assignee: Akira Tanaka
----------------------------------------
With following addition
~~~ ruby
class String
def pretty_print(q)
lines = self.lines
if lines.size > 1
q.group(0, '', '') do
q.seplist(lines, lambda { q.text ' +'; q.breakable }) do |v|
q.pp v
end
end
else
q.text inspect
end
end
end
~~~
a multiline String will print as follows
~~~ text
[9] pry(main)> pp "bundler.rb"=> "module Bundler\n BundlerError = Class.new(Exception)\n def self.setup\n end\nend\n"
{"bundler.rb"=>
"module Bundler\n" +
" BundlerError = Class.new(Exception)\n" +
" def self.setup\n" +
" end\n" +
"end\n"}
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>