ku1ik / rainbow

Ruby gem for colorizing printed text on ANSI terminals
MIT License
813 stars 68 forks source link

Possibility to pass style as symbol #32

Closed mainrs closed 8 years ago

mainrs commented 8 years ago

Is there a possibility to pass the style as a symbol? I wanted to write a generic method for coloring aka:

def colorize(string, foreground, style = :reset)
  Rainbow(string).fg(foreground).style(style)
end

Is there something similar possible?

ku1ik commented 8 years ago

You can use Ruby's public_send like this: Rainbow(string).public_send(style).