redgreenblue 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,55 +1,4 @@
1
- class RGB
2
-
3
- #----------------------------------------------------------------------#
4
- # Class Methods #
5
- #----------------------------------------------------------------------#
6
-
7
- class << self
8
-
9
- # Returns CSS named colors, as per CSS Color Module Level 4.
10
- #
11
- # Optional selector argument can be:
12
- # - String or Regexp (to select by name)
13
- # - RGB color (to select by color)
14
- # - Integer (to select by index).
15
- # Selection by name (string or regular expression) is case-insensitive by default.
16
- #
17
- # @example No Selector
18
- # # All colors
19
- # RGB.css
20
- #
21
- # # Pastels
22
- # RGB.css.select { |c| c.ostwald_cwk[1] > 0.6 }
23
- # @example Select by Name
24
- # # Exact name
25
- # RGB.css 'pink'
26
- #
27
- # # Regular expression
28
- # RGB.css /pink|rose/
29
- #
30
- # @example Select by RGB color
31
- # RGB.css RGB.hex('0ff')
32
- def css(selector=nil)
33
- @@css ||= load_gpl file: ( File.join File.dirname(__FILE__), 'palettes', 'css.gpl' ), freeze: true
34
- case selector
35
- when NilClass
36
- @@css
37
- when String
38
- n = selector.downcase
39
- @@css.select { |c| c.name == n }.first
40
- when Regexp
41
- r = Regexp.new selector.source, Regexp::IGNORECASE
42
- @@css.select { |c| c.name =~ r }
43
- when Integer
44
- @@css[selector]
45
- when self
46
- @@css.select { |c| c == selector }
47
- else
48
- raise ArgumentError, 'Unsupported selector'
49
- end
50
- end
51
-
52
- end
1
+ class RGB::Color
53
2
 
54
3
  #----------------------------------------------------------------------#
55
4
  # Instance Methods #
@@ -112,3 +61,58 @@ class RGB
112
61
  end
113
62
 
114
63
  end
64
+
65
+ #----------------------------------------------------------------------#
66
+ # Module Methods #
67
+ #----------------------------------------------------------------------#
68
+
69
+ module RGB
70
+
71
+ class << self
72
+
73
+ # Returns CSS named colors, as per CSS Color Module Level 4.
74
+ #
75
+ # Optional selector argument can be:
76
+ # - String or Regexp (to select by name)
77
+ # - RGB color (to select by color)
78
+ # - Integer (to select by index).
79
+ # Selection by name (string or regular expression) is case-insensitive by default.
80
+ #
81
+ # @example No Selector
82
+ # # All colors
83
+ # RGB.css
84
+ #
85
+ # # Pastels
86
+ # RGB.css.select { |c| c.ostwald_cwk[1] > 0.6 }
87
+ # @example Select by Name
88
+ # # Exact name
89
+ # RGB.css 'pink'
90
+ #
91
+ # # Regular expression
92
+ # RGB.css /pink|rose/
93
+ #
94
+ # @example Select by RGB color
95
+ # RGB.css RGB.hex('0ff')
96
+ def css(selector=nil)
97
+ @@css ||= load_gpl file: ( File.join File.dirname(__FILE__), 'palettes', 'css.gpl' ), freeze: true
98
+ case selector
99
+ when NilClass
100
+ @@css
101
+ when String
102
+ n = selector.downcase
103
+ @@css.select { |c| c.name == n }.first
104
+ when Regexp
105
+ r = Regexp.new selector.source, Regexp::IGNORECASE
106
+ @@css.select { |c| c.name =~ r }
107
+ when Integer
108
+ @@css[selector]
109
+ when RGB::Color
110
+ @@css.select { |c| c == selector }
111
+ else
112
+ raise ArgumentError, 'Unsupported selector'
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+ end
data/lib/redgreenblue.rb CHANGED
@@ -1,4 +1,23 @@
1
- class RGB
1
+ # The RGB module is the main namespace for redgreenblue.
2
+ #
3
+ # This module has many helper methods for creating RGB::Color objects.
4
+ # The example below shows seven ways to create an RGB::Color object for the exact same color.
5
+ # @example
6
+ # require 'redgreenblue'
7
+ #
8
+ # pink = RGB.new(1, 0.6, 0.8)
9
+ # pink = RGB.rgb(255, 153, 204)
10
+ # pink = RGB.rrggbb(65535, 39321, 52428)
11
+ # pink = RGB.hex('f9c')
12
+ # pink = RGB.hsl(330, 1, 0.8)
13
+ # pink = RGB.hsv(330, 0.4, 1)
14
+ # pink = RGB.at(16751052)
15
+ module RGB
16
+
17
+ # This class represents an RGB color.
18
+ class Color
19
+ end
20
+
2
21
  end
3
22
 
4
23
  %w(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redgreenblue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - lllist.eu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-10 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.2.22
78
+ rubygems_version: 3.3.11
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: A simple Ruby library for handling RGB colors.