Sha256: a90fa8f97a1732eddcdfdd02a2252a33e1abace672dfbfe696a1269b8510648c

Contents?: true

Size: 794 Bytes

Versions: 12

Compression:

Stored size: 794 Bytes

Contents

class NSColor

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

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

    alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
    inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
    if inside
      return "NSColor.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 "NSColor.#{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

12 entries across 12 versions & 1 rubygems

Version Path
sugarcube-2.4.0 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.3.0 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.2.0 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.5 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.4 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.3 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.2 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.1 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.1.0 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.0.2 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.0.1 lib/osx/sugarcube-to_s/nscolor.rb
sugarcube-2.0.0 lib/osx/sugarcube-to_s/nscolor.rb