pnm 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PNM
2
4
 
3
5
  # Base class for all PNM exceptions.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PNM
2
4
 
3
5
  # Abstract base class for +PBM+, +PGM+, and +PPM+ images.
@@ -45,11 +47,11 @@ module PNM
45
47
  type ||= detect_type(pixels, options[:maxgray])
46
48
 
47
49
  # except for type detection, the maxgray option must be ignored for PBM
48
- if type == :pbm
49
- maxgray = nil
50
- else
51
- maxgray = options[:maxgray]
52
- end
50
+ maxgray = if type == :pbm
51
+ nil
52
+ else
53
+ options[:maxgray]
54
+ end
53
55
 
54
56
  image_class = case type
55
57
  when :pbm
@@ -97,7 +99,7 @@ module PNM
97
99
  to_binary
98
100
  end
99
101
 
100
- if file.kind_of?(String)
102
+ if file.is_a?(String)
101
103
  File.binwrite(file, content)
102
104
  else
103
105
  file.binmode
@@ -119,7 +121,7 @@ module PNM
119
121
  "#{type.to_s.upcase} #{width}x#{height} #{type_string}"
120
122
  end
121
123
 
122
- alias :to_s :info
124
+ alias to_s info
123
125
 
124
126
  # Returns a string representation for debugging.
125
127
  def inspect
@@ -135,28 +137,28 @@ module PNM
135
137
  type == other.type && maxgray == other.maxgray && comment == other.comment && pixels == other.pixels
136
138
  end
137
139
 
138
- private
139
-
140
140
  def self.assert_valid_array(pixels) # :nodoc:
141
141
  assert_array_dimensions(pixels)
142
142
  assert_pixel_types(pixels)
143
143
  end
144
+ private_class_method :assert_valid_array
144
145
 
145
146
  def self.assert_array_dimensions(pixels) # :nodoc:
146
147
  msg = "invalid pixel data: Array expected"
147
- raise PNM::ArgumentError, msg unless Array === pixels
148
+ raise PNM::ArgumentError, msg unless pixels.is_a?(Array)
148
149
 
149
150
  msg = "invalid pixel array"
150
-
151
151
  raise PNM::DataError, msg unless pixels.map(&:class).uniq == [Array]
152
+
152
153
  width = pixels.first.size
153
- raise PNM::DataError, msg if width == 0
154
+ raise PNM::DataError, msg if width.zero?
154
155
  raise PNM::DataError, msg unless pixels.map(&:size).uniq == [width]
155
156
  end
157
+ private_class_method :assert_array_dimensions
156
158
 
157
159
  def self.assert_pixel_types(pixels) # :nodoc:
158
160
  pixel_values = pixels.flatten(1)
159
- is_color = (Array === pixel_values.first)
161
+ is_color = pixel_values.first.is_a?(Array)
160
162
 
161
163
  if is_color
162
164
  pixel_values.each {|pixel| assert_valid_color_pixel(pixel) }
@@ -164,43 +166,47 @@ module PNM
164
166
  pixel_values.each {|pixel| assert_valid_pixel(pixel) }
165
167
  end
166
168
  end
169
+ private_class_method :assert_pixel_types
167
170
 
168
171
  def self.assert_valid_pixel(pixel) # :nodoc:
169
- unless Integer === pixel
170
- msg = "invalid pixel value: Integer expected - #{pixel.inspect}"
171
- raise PNM::DataError, msg
172
- end
172
+ return if pixel.is_a?(Integer)
173
+
174
+ msg = "invalid pixel value: Integer expected - #{pixel.inspect}"
175
+ raise PNM::DataError, msg
173
176
  end
177
+ private_class_method :assert_valid_pixel
174
178
 
175
179
  def self.assert_valid_color_pixel(pixel) # :nodoc:
176
- unless Array === pixel && pixel.map {|p| Integer === p } == [true, true, true]
177
- msg = "invalid pixel value: "
178
- msg << "Array of 3 Integers expected - #{pixel.inspect}"
180
+ return if pixel.is_a?(Array) && pixel.size == 3 && pixel.all? {|p| p.is_a?(Integer) }
179
181
 
180
- raise PNM::DataError, msg
181
- end
182
+ msg = "invalid pixel value: ".dup
183
+ msg << "Array of 3 Integers expected - #{pixel.inspect}"
184
+ raise PNM::DataError, msg
182
185
  end
186
+ private_class_method :assert_valid_color_pixel
183
187
 
184
188
  def self.assert_valid_maxgray(maxgray) # :nodoc:
185
189
  return unless maxgray
190
+ return if maxgray.is_a?(Integer) && maxgray > 0 && maxgray <= 255
186
191
 
187
- unless Integer === maxgray && maxgray > 0 && maxgray <= 255
188
- raise PNM::ArgumentError, "invalid maxgray value - #{maxgray.inspect}"
189
- end
192
+ msg = "invalid maxgray value - #{maxgray.inspect}"
193
+ raise PNM::ArgumentError, msg
190
194
  end
195
+ private_class_method :assert_valid_maxgray
191
196
 
192
197
  def self.assert_valid_comment(comment) # :nodoc:
193
198
  return unless comment
199
+ return if comment.is_a?(String)
194
200
 
195
- unless String === comment
196
- raise PNM::ArgumentError, "invalid comment value - #{comment.inspect}"
197
- end
201
+ msg = "invalid comment value - #{comment.inspect}"
202
+ raise PNM::ArgumentError, msg
198
203
  end
204
+ private_class_method :assert_valid_comment
199
205
 
200
206
  def self.sanitize_and_assert_valid_type(type) # :nodoc:
201
207
  return unless type
202
208
 
203
- type = type.to_sym if type.kind_of?(String)
209
+ type = type.to_sym if type.is_a?(String)
204
210
 
205
211
  unless [:pbm, :pgm, :ppm].include?(type)
206
212
  msg = "invalid image type - #{type.inspect}"
@@ -209,9 +215,10 @@ module PNM
209
215
 
210
216
  type
211
217
  end
218
+ private_class_method :sanitize_and_assert_valid_type
212
219
 
213
220
  def self.detect_type(pixels, maxgray) # :nodoc:
214
- if pixels.first.first.kind_of?(Array)
221
+ if pixels.first.first.is_a?(Array)
215
222
  :ppm
216
223
  elsif (maxgray && maxgray > 1) || pixels.flatten.max > 1
217
224
  :pgm
@@ -219,25 +226,27 @@ module PNM
219
226
  :pbm
220
227
  end
221
228
  end
229
+ private_class_method :detect_type
230
+
231
+ private
222
232
 
223
233
  def assert_grayscale_data # :nodoc:
224
- if color_pixels?
225
- msg = "specified type does not match RGB data - #{type.inspect}"
226
- raise PNM::DataError, msg
227
- end
234
+ return unless color_pixels?
235
+
236
+ msg = "specified type does not match RGB data - #{type.inspect}"
237
+ raise PNM::DataError, msg
228
238
  end
229
239
 
230
240
  def assert_pixel_value_range # :nodoc:
231
- unless pixels.flatten.max <= maxgray
232
- raise PNM::DataError, "invalid data: value(s) greater than maxgray"
233
- end
234
- unless pixels.flatten.min >= 0
235
- raise PNM::DataError, "invalid data: value(s) less than zero"
236
- end
241
+ msg = "invalid data: value(s) greater than maxgray"
242
+ raise PNM::DataError, msg unless pixels.flatten.max <= maxgray
243
+
244
+ msg = "invalid data: value(s) less than zero"
245
+ raise PNM::DataError, msg unless pixels.flatten.min >= 0
237
246
  end
238
247
 
239
248
  def header_without_maxgray(encoding) # :nodoc:
240
- header = "#{PNM.magic_number[type][encoding]}\n"
249
+ header = "#{PNM.magic_number[type][encoding]}\n".dup
241
250
  comment_lines.each do |line|
242
251
  header << (line.empty? ? "#\n" : "# #{line}\n")
243
252
  end
@@ -252,7 +261,7 @@ module PNM
252
261
 
253
262
  def comment_lines # :nodoc:
254
263
  return [] unless comment
255
- return [''] if comment.empty?
264
+ return [""] if comment.empty?
256
265
 
257
266
  keep_trailing_null_fields = -1 # magic value for split limit
258
267
  comment.split(/\n/, keep_trailing_null_fields)
@@ -271,11 +280,11 @@ module PNM
271
280
  end
272
281
 
273
282
  def color_pixels? # :nodoc:
274
- (pixels.first.first).kind_of?(Array)
283
+ pixels.first.first.is_a?(Array)
275
284
  end
276
285
 
277
286
  def inspect_string_with_maxgray # :nodoc:
278
- "#<%s:0x%x %s, maxgray=%d>" % [self.class.name, object_id, info, maxgray]
287
+ "#<%s:0x%x %s, maxgray=%d>" % [self.class.name, object_id, info, maxgray]
279
288
  end
280
289
 
281
290
  def inspect_string_without_maxgray # :nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PNM
2
4
 
3
5
  # @private
@@ -26,8 +28,8 @@ module PNM
26
28
  until magic_number
27
29
  token = next_token!(content)
28
30
 
29
- if token.start_with?('#')
30
- comments << token.gsub(/# */, '')
31
+ if token.start_with?("#")
32
+ comments << token.gsub(/# */, "")
31
33
  else
32
34
  magic_number = token
33
35
  end
@@ -36,11 +38,11 @@ module PNM
36
38
  assert_valid_magic_number(magic_number)
37
39
 
38
40
  while tokens.size < token_number[magic_number]
39
- content.gsub!(/\A[ \t\r\n]+/, '')
41
+ content.gsub!(/\A[ \t\r\n]+/, "")
40
42
  token = next_token!(content)
41
43
 
42
- if token.start_with?('#')
43
- comments << token.gsub(/# */, '')
44
+ if token.start_with?("#")
45
+ comments << token.gsub(/# */, "")
44
46
  else
45
47
  tokens << token
46
48
  end
@@ -61,10 +63,10 @@ module PNM
61
63
  assert_value(maxgray, "maxgray") {|x| x > 0 && x <= 255 } if maxgray
62
64
 
63
65
  result = {
64
- :magic_number => magic_number,
65
- :width => width,
66
- :height => height,
67
- :data => content
66
+ magic_number: magic_number,
67
+ width: width,
68
+ height: height,
69
+ data: content
68
70
  }
69
71
  result[:maxgray] = maxgray if maxgray
70
72
  result[:comments] = comments unless comments.empty?
@@ -74,24 +76,24 @@ module PNM
74
76
 
75
77
  def self.token_number
76
78
  {
77
- 'P1' => 2,
78
- 'P2' => 3,
79
- 'P3' => 3,
80
- 'P4' => 2,
81
- 'P5' => 3,
82
- 'P6' => 3
79
+ "P1" => 2,
80
+ "P2" => 3,
81
+ "P3" => 3,
82
+ "P4" => 2,
83
+ "P5" => 3,
84
+ "P6" => 3
83
85
  }
84
86
  end
85
87
 
86
88
  def self.next_token!(content)
87
- delimiter = if content.start_with?('#')
89
+ delimiter = if content.start_with?("#")
88
90
  "\n"
89
91
  else
90
- %r{[ \t\r\n]|(?=#)}
92
+ /[ \t\r\n]|(?=#)/
91
93
  end
92
94
 
93
95
  token, rest = content.split(delimiter, 2)
94
- raise PNM::ParserError, 'not enough tokens in file' unless rest
96
+ raise PNM::ParserError, "not enough tokens in file" unless rest
95
97
 
96
98
  content.replace(rest)
97
99
 
@@ -99,24 +101,24 @@ module PNM
99
101
  end
100
102
 
101
103
  def self.assert_valid_magic_number(magic_number)
102
- unless %w{P1 P2 P3 P4 P5 P6}.include?(magic_number)
103
- msg = "unknown magic number - `#{magic_number}'"
104
- raise PNM::ParserError, msg
105
- end
104
+ return if %w[P1 P2 P3 P4 P5 P6].include?(magic_number)
105
+
106
+ msg = "unknown magic number - `#{magic_number}'"
107
+ raise PNM::ParserError, msg
106
108
  end
107
109
 
108
110
  def self.assert_integer(value_string, value_name)
109
- unless /\A[0-9]+\Z/ === value_string
110
- msg = "#{value_name} must be an integer - `#{value_string}'"
111
- raise PNM::ParserError, msg
112
- end
111
+ return if value_string =~ /\A[0-9]+\Z/
112
+
113
+ msg = "#{value_name} must be an integer - `#{value_string}'"
114
+ raise PNM::ParserError, msg
113
115
  end
114
116
 
115
117
  def self.assert_value(value, name)
116
- unless yield(value)
117
- msg = "invalid #{name} value - `#{value}'"
118
- raise PNM::ParserError, msg
119
- end
118
+ return if yield(value)
119
+
120
+ msg = "invalid #{name} value - `#{value}'"
121
+ raise PNM::ParserError, msg
120
122
  end
121
123
  end
122
124
  end
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PNM
2
- VERSION = '0.5.1'
3
- DATE = '2016-12-26'
4
+ VERSION = "0.5.2"
5
+ DATE = "2019-02-09"
4
6
  end
@@ -1,4 +1,6 @@
1
- require './lib/pnm'
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/pnm"
2
4
 
3
5
  version = PNM::VERSION
4
6
  date = PNM::DATE
@@ -6,40 +8,41 @@ homepage = PNM::HOMEPAGE
6
8
  tagline = PNM::TAGLINE
7
9
 
8
10
  Gem::Specification.new do |s|
9
- s.name = 'pnm'
11
+ s.name = "pnm"
10
12
  s.version = version
11
13
  s.date = date
12
14
 
13
- s.description = 'PNM is a pure Ruby library for creating, reading, ' +
14
- 'and writing of PNM image files (Portable Anymap): ' +
15
- 'PBM (Portable Bitmap), ' +
16
- 'PGM (Portable Graymap), and ' +
17
- 'PPM (Portable Pixmap).'
15
+ s.description = "PNM is a pure Ruby library for creating, reading, " \
16
+ "and writing of PNM image files (Portable Anymap): " \
17
+ "PBM (Portable Bitmap), " \
18
+ "PGM (Portable Graymap), and " \
19
+ "PPM (Portable Pixmap)."
18
20
  s.summary = "PNM - #{tagline}"
19
21
 
20
- s.authors = ['Marcus Stollsteimer']
21
- s.email = 'sto.mar@web.de'
22
+ s.authors = ["Marcus Stollsteimer"]
23
+ s.email = "sto.mar@web.de"
22
24
  s.homepage = homepage
23
25
 
24
- s.license = 'GPL-3.0'
26
+ s.license = "GPL-3.0"
25
27
 
26
- s.required_ruby_version = '>= 1.9.3'
28
+ s.required_ruby_version = ">= 1.9.3"
27
29
 
28
- s.add_development_dependency 'rake', '>= 10.0'
29
- s.add_development_dependency 'minitest', '>= 5.0'
30
+ s.add_development_dependency "minitest", ">= 5.0"
31
+ s.add_development_dependency "rake", ">= 10.0"
30
32
 
31
- s.require_paths = ['lib']
33
+ s.require_paths = ["lib"]
32
34
 
33
- s.test_files = Dir.glob('test/**/test_*.rb')
35
+ s.test_files = Dir.glob("test/**/test_*.rb")
34
36
 
35
- s.files = %w{
37
+ s.files =
38
+ %w[
36
39
  README.md
37
40
  Rakefile
38
41
  pnm.gemspec
39
42
  .yardopts
40
- } +
41
- Dir.glob('{benchmark,lib,test}/**/*')
43
+ ] +
44
+ Dir.glob("{benchmark,lib,test}/**/*")
42
45
 
43
- s.extra_rdoc_files = ['README.md']
44
- s.rdoc_options = ['--charset=UTF-8', '--main=README.md']
46
+ s.extra_rdoc_files = ["README.md"]
47
+ s.rdoc_options = ["--charset=UTF-8", "--main=README.md"]
45
48
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # test_converter.rb: Unit tests for the PNM library.
2
4
  #
3
- # Copyright (C) 2013-2016 Marcus Stollsteimer
5
+ # Copyright (C) 2013-2019 Marcus Stollsteimer
4
6
 
5
- require 'minitest/autorun'
6
- require 'pnm/converter'
7
+ require "minitest/autorun"
8
+ require "pnm/converter"
7
9
 
8
10
 
9
11
  describe PNM::Converter do
@@ -11,43 +13,44 @@ describe PNM::Converter do
11
13
  before do
12
14
  @converter = PNM::Converter
13
15
 
14
- @pbm6 = {
15
- :width => 6,
16
- :height => 2,
17
- :array => [[0,1,0,0,1,1], [0,0,0,1,1,1]],
18
- :ascii => "0 1 0 0 1 1\n0 0 0 1 1 1\n",
19
- :binary => ['4C1C'].pack('H*')
20
- }
16
+ @pbm6 = {
17
+ width: 6,
18
+ height: 2,
19
+ array: [[0, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1]],
20
+ ascii: "0 1 0 0 1 1\n0 0 0 1 1 1\n",
21
+ binary: ["4C1C"].pack("H*")
22
+ }
21
23
 
22
24
  @pbm14 = {
23
- :width => 14,
24
- :height => 2,
25
- :array => [[0,0,1,1,1,0,0,0,1,1,0,0,1,0], [0,1,0,1,1,0,1,1,1,0,1,1,1,1]],
26
- :ascii => "0 0 1 1 1 0 0 0 1 1 0 0 1 0\n0 1 0 1 1 0 1 1 1 0 1 1 1 1\n",
27
- :binary => ['38C85BBC'].pack('H*')
28
- }
25
+ width: 14,
26
+ height: 2,
27
+ array: [[0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0],
28
+ [0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1]],
29
+ ascii: "0 0 1 1 1 0 0 0 1 1 0 0 1 0\n0 1 0 1 1 0 1 1 1 0 1 1 1 1\n",
30
+ binary: ["38C85BBC"].pack("H*")
31
+ }
29
32
 
30
33
  @pbm = @pbm14
31
34
 
32
- @pgm = {
33
- :width => 4,
34
- :height => 3,
35
- :array => [[0, 85, 170, 255], [85, 170, 255, 0], [170, 255, 0, 85]],
36
- :ascii => "0 85 170 255\n85 170 255 0\n170 255 0 85\n",
37
- :binary => ['0055AAFF55AAFF00AAFF0055'].pack('H*')
38
- }
39
-
40
- @ppm = {
41
- :width => 3,
42
- :height => 2,
43
- :array => [[[0,128,255], [128,255,0], [255,0,128]],
44
- [[255,128,0], [128,0,255], [0,255,128]]],
45
- :ascii => "0 128 255 128 255 0 255 0 128\n255 128 0 128 0 255 0 255 128\n",
46
- :binary => ['0080FF80FF00FF0080FF80008000FF00FF80'].pack('H*')
47
- }
48
- end
49
-
50
- it 'can convert from ASCII encoded PBM data' do
35
+ @pgm = {
36
+ width: 4,
37
+ height: 3,
38
+ array: [[0, 85, 170, 255], [85, 170, 255, 0], [170, 255, 0, 85]],
39
+ ascii: "0 85 170 255\n85 170 255 0\n170 255 0 85\n",
40
+ binary: ["0055AAFF55AAFF00AAFF0055"].pack("H*")
41
+ }
42
+
43
+ @ppm = {
44
+ width: 3,
45
+ height: 2,
46
+ array: [[[0, 128, 255], [128, 255, 0], [255, 0, 128]],
47
+ [[255, 128, 0], [128, 0, 255], [0, 255, 128]]],
48
+ ascii: "0 128 255 128 255 0 255 0 128\n255 128 0 128 0 255 0 255 128\n",
49
+ binary: ["0080FF80FF00FF0080FF80008000FF00FF80"].pack("H*")
50
+ }
51
+ end
52
+
53
+ it "can convert from ASCII encoded PBM data" do
51
54
  width = @pbm[:width]
52
55
  height = @pbm[:height]
53
56
  data = @pbm[:ascii]
@@ -56,7 +59,7 @@ describe PNM::Converter do
56
59
  @converter.ascii2array(:pbm, width, height, data).must_equal expected
57
60
  end
58
61
 
59
- it 'can convert from ASCII encoded PGM data' do
62
+ it "can convert from ASCII encoded PGM data" do
60
63
  width = @pgm[:width]
61
64
  height = @pgm[:height]
62
65
  data = @pgm[:ascii]
@@ -65,7 +68,7 @@ describe PNM::Converter do
65
68
  @converter.ascii2array(:pgm, width, height, data).must_equal expected
66
69
  end
67
70
 
68
- it 'can convert from ASCII encoded PPM data' do
71
+ it "can convert from ASCII encoded PPM data" do
69
72
  width = @ppm[:width]
70
73
  height = @ppm[:height]
71
74
  data = @ppm[:ascii]
@@ -74,7 +77,7 @@ describe PNM::Converter do
74
77
  @converter.ascii2array(:ppm, width, height, data).must_equal expected
75
78
  end
76
79
 
77
- it 'accepts ASCII encoded PBM data with omitted whitespace' do
80
+ it "accepts ASCII encoded PBM data with omitted whitespace" do
78
81
  width = 4
79
82
  height = 3
80
83
  data = " 010100\n000110"
@@ -83,7 +86,7 @@ describe PNM::Converter do
83
86
  @converter.ascii2array(:pbm, width, height, data).must_equal expected
84
87
  end
85
88
 
86
- it 'accepts ASCII encoded PGM data with arbitrary whitespace' do
89
+ it "accepts ASCII encoded PGM data with arbitrary whitespace" do
87
90
  width = 4
88
91
  height = 3
89
92
  data = " \n 10 90\t170\r250\n90 \t170 250 \t\r\n\t 10\n\n\n170\n250\n10\n90\n"
@@ -92,7 +95,7 @@ describe PNM::Converter do
92
95
  @converter.ascii2array(:pgm, width, height, data).must_equal expected
93
96
  end
94
97
 
95
- it 'can convert from binary encoded PBM data (width 6)' do
98
+ it "can convert from binary encoded PBM data (width 6)" do
96
99
  width = @pbm6[:width]
97
100
  height = @pbm6[:height]
98
101
  data = @pbm6[:binary]
@@ -101,7 +104,7 @@ describe PNM::Converter do
101
104
  @converter.binary2array(:pbm, width, height, data).must_equal expected
102
105
  end
103
106
 
104
- it 'can convert from binary encoded PBM data (width 14)' do
107
+ it "can convert from binary encoded PBM data (width 14)" do
105
108
  width = @pbm14[:width]
106
109
  height = @pbm14[:height]
107
110
  data = @pbm14[:binary]
@@ -110,7 +113,7 @@ describe PNM::Converter do
110
113
  @converter.binary2array(:pbm, width, height, data).must_equal expected
111
114
  end
112
115
 
113
- it 'can convert from binary encoded PGM data' do
116
+ it "can convert from binary encoded PGM data" do
114
117
  width = @pgm[:width]
115
118
  height = @pgm[:height]
116
119
  data = @pgm[:binary]
@@ -119,7 +122,7 @@ describe PNM::Converter do
119
122
  @converter.binary2array(:pgm, width, height, data).must_equal expected
120
123
  end
121
124
 
122
- it 'can convert from binary encoded PPM data' do
125
+ it "can convert from binary encoded PPM data" do
123
126
  width = @ppm[:width]
124
127
  height = @ppm[:height]
125
128
  data = @ppm[:binary]
@@ -128,7 +131,7 @@ describe PNM::Converter do
128
131
  @converter.binary2array(:ppm, width, height, data).must_equal expected
129
132
  end
130
133
 
131
- it 'accepts an additional whitespace character for binary encoded data' do
134
+ it "accepts an additional whitespace character for binary encoded data" do
132
135
  width = @pbm14[:width]
133
136
  height = @pbm14[:height]
134
137
  data = @pbm14[:binary] + "\t"
@@ -137,56 +140,56 @@ describe PNM::Converter do
137
140
  @converter.binary2array(:pbm, width, height, data).must_equal expected
138
141
  end
139
142
 
140
- it 'can convert to ASCII encoded PBM data' do
143
+ it "can convert to ASCII encoded PBM data" do
141
144
  data = @pbm[:array]
142
145
  expected = @pbm[:ascii]
143
146
 
144
147
  @converter.array2ascii(data).must_equal expected
145
148
  end
146
149
 
147
- it 'can convert to ASCII encoded PGM data' do
150
+ it "can convert to ASCII encoded PGM data" do
148
151
  data = @pgm[:array]
149
152
  expected = @pgm[:ascii]
150
153
 
151
154
  @converter.array2ascii(data).must_equal expected
152
155
  end
153
156
 
154
- it 'can convert to ASCII encoded PPM data' do
157
+ it "can convert to ASCII encoded PPM data" do
155
158
  data = @ppm[:array]
156
159
  expected = @ppm[:ascii]
157
160
 
158
161
  @converter.array2ascii(data).must_equal expected
159
162
  end
160
163
 
161
- it 'can convert to binary encoded PBM data (width 6)' do
164
+ it "can convert to binary encoded PBM data (width 6)" do
162
165
  data = @pbm6[:array]
163
166
  expected = @pbm6[:binary]
164
167
 
165
168
  @converter.array2binary(:pbm, data).must_equal expected
166
169
  end
167
170
 
168
- it 'can convert to binary encoded PBM data (width 14)' do
171
+ it "can convert to binary encoded PBM data (width 14)" do
169
172
  data = @pbm14[:array]
170
173
  expected = @pbm14[:binary]
171
174
 
172
175
  @converter.array2binary(:pbm, data).must_equal expected
173
176
  end
174
177
 
175
- it 'can convert to binary encoded PGM data' do
178
+ it "can convert to binary encoded PGM data" do
176
179
  data = @pgm[:array]
177
180
  expected = @pgm[:binary]
178
181
 
179
182
  @converter.array2binary(:pgm, data).must_equal expected
180
183
  end
181
184
 
182
- it 'can convert to binary encoded PPM data' do
185
+ it "can convert to binary encoded PPM data" do
183
186
  data = @ppm[:array]
184
187
  expected = @ppm[:binary]
185
188
 
186
189
  @converter.array2binary(:ppm, data).must_equal expected
187
190
  end
188
191
 
189
- it 'can calculate correct byte widths for a PBM image' do
192
+ it "can calculate correct byte widths for a PBM image" do
190
193
  @converter.byte_width(:pbm, 0).must_equal 0
191
194
  @converter.byte_width(:pbm, 1).must_equal 1
192
195
  @converter.byte_width(:pbm, 7).must_equal 1
@@ -196,11 +199,11 @@ describe PNM::Converter do
196
199
  @converter.byte_width(:pbm, 65).must_equal 9
197
200
  end
198
201
 
199
- it 'can calculate correct byte widths for a PGM image' do
202
+ it "can calculate correct byte widths for a PGM image" do
200
203
  @converter.byte_width(:pgm, 13).must_equal 13
201
204
  end
202
205
 
203
- it 'can calculate correct byte widths for a PPM image' do
206
+ it "can calculate correct byte widths for a PPM image" do
204
207
  @converter.byte_width(:ppm, 13).must_equal 39
205
208
  end
206
209
  end