Method: Inker::Color#to_s

Defined in:
lib/inker/color.rb

#to_s(format = 'hex') ⇒ String

Convert color to string in the specified format.

Parameters:

  • format (String) (defaults to: 'hex')

    indicates the format to which to output the color (default: hex)

Returns:

  • (String)

    a string representation of the color



180
181
182
183
184
185
186
187
188
189
190
# File 'lib/inker/color.rb', line 180

def to_s(format = 'hex')
  case format.to_s.strip.downcase
  when 'hex6' then hex6
  when 'rgb'  then rgb
  when 'rgba' then rgba
  when 'hsl'  then hsl
  when 'hsla' then hsla
  else
    hex
  end
end