-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deviate from ruby/pretty_print and enrich the API #57
Conversation
|
case delim | ||
in nil then ['', ''] | ||
in String | Symbol then [delim, delim] | ||
in Array then delim.values_at(0, 1).map(&:to_s) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should extract this part to mixins
since we have meen using it twice.
@@ -9,13 +9,13 @@ | |||
# By using a callable: | |||
space = ->(n) { '---' * n } | |||
|
|||
printer = Oppen::Wadler.new(space: space) | |||
printer = Oppen::Wadler.new(indent: 2, space: space) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
printer_width_default = Oppen::Wadler.new(indent: 2) | ||
printer_width_narrow = Oppen::Wadler.new(indent: 2, width: width) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
lib/wadler/print.rb
Outdated
# @return [Integer] | ||
# the starting indentation level for the whole printer. | ||
attr_reader :base_indent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You never set the value of @base_indent
. Maybe you intended a getter for @indent
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's wrong indeed. base indent is current indent. Maybe we should also kill the setter. It doesn't make sense.
# @param indent [Integer] | ||
# the default indentation amount for {group} and {nest}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite being longer, I would much rather go with default_indent
. We can live with indent
if you find it too long.
Makes for a simpler, more declarative API.
It's still there since project initialization.
They're _"aliases"_ to `group`.
4a10fd0
to
39e72cc
Compare
7fa5121
to
9fbc705
Compare
Which makes chaining calls possible => better looking programs
This is in preparation for the next commit which introduces the `space` method to actually print a space. Besides, it's technically a space generator.
It adds breakables next to delimiters, and gives more control to the caller. Will be useful in the next commits when we add more vocab.
20c8bcc
to
60a44e3
Compare
Addresses many points in #55