Sha256: bf6f81a5a7114c153f7fc7695ee0eb4a5c2383bb23c0708debefd33ec45a88c3

Contents?: true

Size: 794 Bytes

Versions: 48

Compression:

Stored size: 794 Bytes

Contents

class UIColor

  def to_s
    return super unless self.respond_to?(:alpha)

    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
    return super unless self.respond_to?(:alpha)

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

end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
sugarcube-1.3.5 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.4 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.3 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.2 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.1 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.0 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.1.0 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.0.7 lib/sugarcube-to_s/uicolor.rb