piotrmurach/pastel

detach problem

kylekyle opened this issue · 4 comments

In Pry, in the OS X terminal, detach doesn't work as the README suggests:

pry> error = pastel.red.on_bold.detach
=> #<Pastel::Detached styles=[:red, :on_bold]>
pry> error('Error!')
NoMethodError: undefined method `error' for main:Object
from (pry):19:in `__pry__'

Running pry 0.10.1, pastel 0.5.0, and Mac OS 10.10.5.

I think the README is in error; error is a callable object, but it's not a method. This demonstrates 2 ways to use it (since foo.(bar) is the same as foo.call(bar)):

[1] pry(main)> require 'pastel'
=> true
[2] pry(main)> error = Pastel.new.red.bold.detach
=> #<Pastel::Detached styles=[:red, :bold]>
[3] pry(main)> error('Error!')
NoMethodError: undefined method `error' for main:Object
from (pry):3:in `__pry__'
[4] pry(main)> error.call('Error!')
=> "\e[31;1mError!\e[0m"
[5] pry(main)> error.('Error!')
=> "\e[31;1mError!\e[0m"

The README could be corrected by the addition of a period.

@amcaplan Thanks for clearing this up. The docs have been updated here. I've added ability to use array like access error['Error!']. Released v0.5.1 with the fix.

Also, on_bold should be changed to bold.

Example fixed. I take documentation very seriously, thanks for your contribution!