Sha256: 73cf414fdf8fb6a111cd1e2c201bf55ba28385dc478dcc40499ffd7316f910dd

Contents?: true

Size: 694 Bytes

Versions: 3

Compression:

Stored size: 694 Bytes

Contents

class UIColor

  def to_s
    alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
    system_color = system_name
    return "UIColor.#{system_color}#{alpha_s}" if system_color

    alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
    inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
    if inside
      return "UIColor.color(#{inside}#{alpha_s})"
    else
      super
    end
  end

  def inspect
    alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
    if system_name
      return "UIColor.#{system_name}#{alpha_s}"
    elsif hex
      return "'#{hex}'.uicolor#{alpha_s}"
    elsif css_name
      return ":#{css_name}.uicolor#{alpha_s}"
    else
      super
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sugarcube-0.20.0 lib/sugarcube/to_s/uicolor.rb
sugarcube-0.19.5 lib/sugarcube/to_s/uicolor.rb
sugarcube-0.19.4 lib/sugarcube/to_s/uicolor.rb