imageparser 0.0.3 → 0.0.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 +4 -4
- data/lib/imageparser.rb +10 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a1b5a6df5b0fc38d8d29d0a6e6158d27dc06b4f
|
4
|
+
data.tar.gz: 5e234d10606d74c6670d2be699c2b838f2aab8aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2fe83421c08af9db6bdf6b7b7699b0ee5e5aafe9fe45936b542a433527d41f47677c30c77fbf21a1441b4ebcb1299292eeffd34a0a5553443c970c1328d886d
|
7
|
+
data.tar.gz: 2d4bae27e06e34e6751305c9652749aadd70902e6cbab64aee892e838c1b4d49356df7bd25d18b1a1ca427e7051e58935790670d2b01e002156ae11bfa0dcbc0
|
data/lib/imageparser.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Supports PPM and PTF file formats.
|
4
4
|
class ImageParser
|
5
|
-
# File descriptor reading accessor
|
5
|
+
# File descriptor reading accessor.
|
6
6
|
attr_accessor :con
|
7
7
|
|
8
8
|
# Initialize the file
|
@@ -18,19 +18,20 @@ class ImageParser
|
|
18
18
|
# Add parsed results into the hash `info`.
|
19
19
|
#
|
20
20
|
# These results are, the header, the width, the height, the RGB max value, the raster and the raster grid.
|
21
|
+
#
|
21
22
|
# Example: parse_ppm(hash)
|
22
23
|
#
|
23
|
-
# hash
|
24
|
+
# hash, :header = "P6"
|
24
25
|
#
|
25
|
-
# hash
|
26
|
+
# hash, :width = 4
|
26
27
|
#
|
27
|
-
# hash
|
28
|
+
# hash, :height = 4
|
28
29
|
#
|
29
|
-
# hash
|
30
|
+
# hash, :rgb = 255
|
30
31
|
#
|
31
|
-
# hash
|
32
|
+
# hash, :raster = [255, 42, 55, ..]
|
32
33
|
#
|
33
|
-
# hash
|
34
|
+
# hash, :raster_grid = [[34, 43, 55], ..]
|
34
35
|
def parse_ppm(info)
|
35
36
|
info[:header] = @con.split(" ")[0] if @con.split(" ")[0] == "P6"
|
36
37
|
info[:width] = @con.split(" ")[1].to_i if @con.split(" ")[1].to_i > 0
|
@@ -48,9 +49,9 @@ class ImageParser
|
|
48
49
|
#
|
49
50
|
# Example: parse_ptf(hash)
|
50
51
|
#
|
51
|
-
# hash
|
52
|
+
# hash, :header = "PTF1"
|
52
53
|
#
|
53
|
-
# hash
|
54
|
+
# hash, :color_info = [3, 2, 33, 3]
|
54
55
|
def parse_ptf(info)
|
55
56
|
info[:header] = @con.split(" ")[0] if @con.split(" ")[0] == "PTF1"
|
56
57
|
info[:color_info] = @con.split(",")[1..-1].map {|s| s.delete ' '}
|