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.5.6 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.5 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.4 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.3 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.2 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.1 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.5.0 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.6 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.5 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.4 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.3 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.2 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.1 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.4.0 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.11 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.10 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.9 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.8 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.7 lib/sugarcube-to_s/uicolor.rb
sugarcube-1.3.6 lib/sugarcube-to_s/uicolor.rb