abachrome 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb85b148dce0bd2caf5ee135348d4b3733123ba4e139aad387c20071e9a3fb0d
4
- data.tar.gz: 9f2f1fab202ceaa5f448b49c44fb5d6d8ecd91fbb9998878aa0f397f5a228745
3
+ metadata.gz: 51acc020e50052f3aacc9d0e847809f62d84111fad86feb8889e3dc324d17385
4
+ data.tar.gz: 8649cab609da6a1c70dd94f9e77adf01b3fee441b8586d73dbcb2822c15eb7f2
5
5
  SHA512:
6
- metadata.gz: 71ff411b276fc51c075d15c19d88db9b177850b194c55dab03b053f17d0c77d32de63ef1e5d4f2d3fb01a7873efcc22f7055307b2b44a72c6e4089a91c924cda
7
- data.tar.gz: 7744046e683c0bff375b03888917c74b98a6a62d9dba24c52c6c9b7c39a5f450c07e6eb1dbc510f11c3e2378a67b5fc3fe1252d5da716c25ef75463c20950e12
6
+ metadata.gz: 23b5d9b1aa20997c618adf7a337d7f85d533cb937d6d5005f4030dcb96a0b4f88a106ad9c311ecf5a7139a3b09a0ee54502133e6586a78e2983056b41cad2648
7
+ data.tar.gz: 5a9850d26a1e83b6b803de4862d5267499dfe92c752deb54abfef992c80239f83bf8af9f3095c445dcc61bc7a2bd40daa6afaaf443fd997d521789db467aca50
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.4] - 2025-10-12
4
+
5
+ - Added `Color#to_hex` method for convenient hex string output
6
+ - Added `Abachrome.parse` method for parsing CSS color strings
7
+
3
8
  ## [0.1.3] - 2025-10-12
4
9
 
5
10
  - Enhanced color parsing with support for additional CSS formats
@@ -134,7 +134,7 @@ module Abachrome
134
134
  end
135
135
 
136
136
  # Returns a string representation of the color in the format "ColorSpaceName(coord1, coord2, coord3, alpha)"
137
- #
137
+ #
138
138
  # @return [String] A human-readable string representation of the color showing its
139
139
  # color space name, coordinate values rounded to 3 decimal places, and alpha value
140
140
  # (if not 1.0)
@@ -144,6 +144,14 @@ module Abachrome
144
144
  "#{color_space.name}(#{coord_str}#{alpha_str})"
145
145
  end
146
146
 
147
+ # Returns the color as a hexadecimal string representation.
148
+ #
149
+ # @return [String] A hex color string in the format "#RRGGBB" or "#RRGGBBAA" if alpha < 1.0
150
+ def to_hex
151
+ require_relative "outputs/css"
152
+ Outputs::CSS.format_hex(self)
153
+ end
154
+
147
155
  private
148
156
 
149
157
  # Validates that the number of coordinates matches the expected number for the color space.
@@ -1,5 +1,5 @@
1
1
  #
2
2
 
3
3
  module Abachrome
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/abachrome.rb CHANGED
@@ -129,7 +129,7 @@ module Abachrome
129
129
  end
130
130
 
131
131
  # Creates a color object from a CSS color name.
132
- #
132
+ #
133
133
  # @param color_name [String] The CSS color name (e.g., 'red', 'blue', 'cornflowerblue').
134
134
  # Case-insensitive.
135
135
  # @return [Abachrome::Color, nil] A color object in the RGB color space if the name is valid,
@@ -141,6 +141,15 @@ module Abachrome
141
141
  from_rgb(*rgb_values.map { |v| v / 255.0 })
142
142
  end
143
143
 
144
+ # Parses a CSS color string and returns a Color object.
145
+ #
146
+ # @param css_string [String] The CSS color string to parse (e.g., "#ff0000", "rgb(255, 0, 0)", "red")
147
+ # @return [Abachrome::Color, nil] A Color object if parsing succeeds, nil otherwise
148
+ def parse(css_string)
149
+ require_relative "abachrome/parsers/css"
150
+ Parsers::CSS.parse(css_string)
151
+ end
152
+
144
153
  # Convert a color from its current color space to another color space.
145
154
  #
146
155
  # @param color [Abachrome::Color] The color object to convert
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abachrome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durable Programming