Skip to content
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

Enhancement: Rainbow.clear? #56

Closed
ddoherty03 opened this issue Apr 5, 2017 · 6 comments
Closed

Enhancement: Rainbow.clear? #56

ddoherty03 opened this issue Apr 5, 2017 · 6 comments

Comments

@ddoherty03
Copy link

ddoherty03 commented Apr 5, 2017

I am using rainbow to build up tables with possibly colored components, and I need to compute the width of a string that may or may not be rainbowized. I would like to have a method on Rainbow that would return just the wrapped string without any escape codes if the string is already wrapped or just the string otherwise.

Then I could calculate the width of an element that may or may not be wrapped with something like

xx = Rainbow("hello").color(:auqamarine).blink
yy = 'hello'
Rainbow.clear(xx) # => 'hello'
Rainbow.clear(yy) # => 'hello'
Rainbow.clear(xx).length # => 6
Rainbow.clear(yy).length # => 6

In the meantime, any easy way to do this with current gem?
Also, thanks for a great gem.

@ku1ik
Copy link
Owner

ku1ik commented Apr 11, 2017

There's no method in the current version of rainbow for this. But we have PR for exactly this: #54 :)

@ddoherty03
Copy link
Author

Thanks, @sickill. I would vote for a less ponderous name, though, than 'strip_ascii_escape', something like 'clear' or 'wipe', etc.

@olleolleolle
Copy link
Collaborator

@ddoherty03 @sickill The #54 is now merged.

Is this issue "fixed" with that?

@ku1ik
Copy link
Owner

ku1ik commented Sep 5, 2017

It's called uncolor now and I'd say that fixes this issue indeed :)

@ddoherty03
Copy link
Author

@sickill, yes indeed. Thanks for getting to this.

@olleolleolle
Copy link
Collaborator

Thanks, all; closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants