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

Colorize attaches properties to the String #6

Closed
siddarth opened this issue Jun 12, 2012 · 4 comments
Closed

Colorize attaches properties to the String #6

siddarth opened this issue Jun 12, 2012 · 4 comments

Comments

@siddarth
Copy link

Ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0].

>> require 'colorize'
=> true
>> require 'yaml'
=> true
>> s = 'haha'
=> "haha"
>> puts s.colorize(:background => :red)
haha
=> nil
>> s
=> "haha"
>> YAML.dump(s)
=> "--- !str \nstr: haha\n\"@color\": 9\n\"@mode\": 0\n\"@uncolorized\": !str \n  str: haha\n  \"@color\": 9\n  \"@mode\": 0\n"
@siddarth
Copy link
Author

(Got around this by duping the String, but figured I'd throw this here in case other people were having similar issues).

@Wardrop
Copy link

Wardrop commented Feb 10, 2014

Yep, another side-effect of this is it causes an exception to be raised when colorised is called on a frozen string. If you're going to monkey patch something like String, I would never create instance variables if I could at all avoid it.

@fazibear
Copy link
Owner

In class_parameters branch https://github.com/fazibear/colorize/tree/class_parameters, i moved colorize parameters to class variable. It should work in this case.

@fazibear
Copy link
Owner

New refactored version don't use any properties.

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