rgbify 0.0.2 → 0.0.3
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 +5 -5
- data/lib/rgbify.rb +24 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 64e70c799f828463179a92989aeaa1241885acfbb6e22c17dc0164f21be78a96
|
4
|
+
data.tar.gz: 74d51ab531ffaee8d5831219dcdcffe21b6bb3aac40f0be66e244019eb561427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357f792718461a1b9c4d7feed109f3939ee6e53c271e2b8b0f28ab4aac684cacb492e3ab77dfd3a99340042e28424f7f6ce33a63d58eac55149a2e70ac55c664
|
7
|
+
data.tar.gz: c6679af9eabca2daecccb6bfe160d09ae7cf11f86763a219159593159dd9a07e5d77a195352230661cadbf20fbd0d9eb5dae34a4a4cdf75627e2355d8a20d59f
|
data/lib/rgbify.rb
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
class RGB
|
2
|
+
attr_reader :r, :g, :b
|
3
|
+
|
4
|
+
def initialize(array)
|
5
|
+
@r = array[0]
|
6
|
+
@g = array[1]
|
7
|
+
@b = array[2]
|
8
|
+
end
|
9
|
+
|
10
|
+
def [](int)
|
11
|
+
case int
|
12
|
+
when 0
|
13
|
+
@r
|
14
|
+
when 1
|
15
|
+
@g
|
16
|
+
when 2
|
17
|
+
@b
|
18
|
+
else
|
19
|
+
raise "Out of bounds"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
1
24
|
def rgbify(hex)
|
2
25
|
if hex[0] == "#" && hex.length == 7
|
3
26
|
x = hex[1..-1]
|
@@ -6,8 +29,8 @@ def rgbify(hex)
|
|
6
29
|
x.each do |y|
|
7
30
|
array << y.hex
|
8
31
|
end
|
32
|
+
return RGB.new(array)
|
9
33
|
else
|
10
34
|
raise "Please Input valid Hexcode i.e. #ffffff"
|
11
35
|
end
|
12
|
-
return array
|
13
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgbify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Ong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple gem to convert hexcode to rgb
|
14
14
|
email: nicholasowh@hotmail.com
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.
|
40
|
+
rubygems_version: 2.7.3
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: rgbify hexcode
|