imageparser 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/imageparser.rb +15 -0
  3. metadata +7 -9
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b253dac11ff248c2027a133b165cf0ea8d81c8cd
4
+ data.tar.gz: d7e1294443bc68d552a039da11210d75afd1ac79
5
+ SHA512:
6
+ metadata.gz: 3261ca8d0f8745404d7f834ac0b5c797b9d6cd4a019d57fd94ad9d82cff0ba47c7a6f7e5dab8e97b84112dfd1ca60635d2ec93221b1efbb9fe59c77c3cacabe4
7
+ data.tar.gz: 4ed825dbe16e819e534f39cd5b3bdba3bea9c1e2d41b2c59db9cb67deb88c4f2706089c6e602dbd88f78d9a10fb1483a96b56764f34ea9dfd732bcc2b6410123
data/lib/imageparser.rb CHANGED
@@ -1,14 +1,26 @@
1
1
  # Image Parser
2
+ #
2
3
  # Supports PPM and PTF file formats.
3
4
  class ImageParser
5
+ # File descriptor reading accessor
4
6
  attr_accessor :con
7
+
8
+ # Initialize the file
9
+ #
10
+ # Can be nil, but then it won't create
11
+ # the file descriptor.
5
12
  def initialize(file=nil)
6
13
  @con = File.read(file, mode: 'rb') if file
7
14
  end
8
15
 
9
16
  # Parse a PPM file.
17
+ #
10
18
  # Add parsed results into the hash `info`.
11
19
  # These results are, the header, the width, the height, the RGB max value, the raster and the raster grid.
20
+ # Example: parse_ppm(hash)
21
+ # => hash[:header] = "P6", hash[:width] = 4, hash[:height] = 4, hash[:rgb] = 255,
22
+ # => hash[:raster] = [255, 42, 55, ..], hash[:raster_grid] = [[34, 43, 55], ..]
23
+
12
24
  def parse_ppm(info)
13
25
  info[:header] = @con.split(" ")[0] if @con.split(" ")[0] == "P6"
14
26
  info[:width] = @con.split(" ")[1].to_i if @con.split(" ")[1].to_i > 0
@@ -19,8 +31,11 @@ class ImageParser
19
31
  end
20
32
 
21
33
  # Parse a PTF file.
34
+ #
22
35
  # Add parsed results into hash `info`.
23
36
  # These results are, the header and the color information.
37
+ # Example: parse_ptf(hash)
38
+ # hash[:header] = "PTF1", hash[:color_info] = [3, 2, 33, 3]
24
39
  def parse_ptf(info)
25
40
  info[:header] = @con.split(" ")[0] if @con.split(" ")[0] == "PTF1"
26
41
  info[:color_info] = @con.split(",")[1..-1].map {|s| s.delete ' '}
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imageparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Chris Himpon
@@ -11,7 +10,7 @@ bindir: bin
11
10
  cert_chain: []
12
11
  date: 2015-03-06 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Image Parsing Gem
13
+ description: Image Parsing Gem for PPM and PTF files.
15
14
  email: synattack@hotmail.com
16
15
  executables: []
17
16
  extensions: []
@@ -21,26 +20,25 @@ files:
21
20
  homepage: http://rubygems.org/gems/imageparser
22
21
  licenses:
23
22
  - GPLv2
23
+ metadata: {}
24
24
  post_install_message:
25
25
  rdoc_options: []
26
26
  require_paths:
27
27
  - lib
28
28
  required_ruby_version: !ruby/object:Gem::Requirement
29
- none: false
30
29
  requirements:
31
- - - ! '>='
30
+ - - ">="
32
31
  - !ruby/object:Gem::Version
33
32
  version: '0'
34
33
  required_rubygems_version: !ruby/object:Gem::Requirement
35
- none: false
36
34
  requirements:
37
- - - ! '>='
35
+ - - ">="
38
36
  - !ruby/object:Gem::Version
39
37
  version: '0'
40
38
  requirements: []
41
39
  rubyforge_project:
42
- rubygems_version: 1.8.23
40
+ rubygems_version: 2.4.6
43
41
  signing_key:
44
- specification_version: 3
42
+ specification_version: 4
45
43
  summary: Image Parsing
46
44
  test_files: []