apple_png 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -195,7 +195,13 @@ static int readPngChunks(VALUE self, const char *oldPNG, size_t oldPngLength, dy
195
195
  return APPLE_PNG_OK;
196
196
  }
197
197
 
198
- /* convert an apple png data string to a standard png data string */
198
+ /*
199
+ @!visibility protected
200
+ Convert an Apple PNG data string to a standard PNG data string
201
+ @note This sets #width and #height on the ApplePng instance as a side effect
202
+ @param data [String] Binary string containing Apple PNG data
203
+ @return [String] Binary string containing standard PNG data
204
+ */
199
205
  static VALUE ApplePng_convert_apple_png(VALUE self, VALUE data) {
200
206
  int error;
201
207
  VALUE ret;
@@ -229,7 +235,12 @@ static VALUE ApplePng_convert_apple_png(VALUE self, VALUE data) {
229
235
  return ret;
230
236
  }
231
237
 
232
- /* this is a quick way to get the width and height from png data without converting the file */
238
+ /*
239
+ @!visibility protected
240
+ Get the width and height from PNG data without actually converting it.
241
+ @note This sets #width and #height on the ApplePng instance.
242
+ @param data [String] Binary string containing Apple PNG data
243
+ */
233
244
  static VALUE ApplePng_get_dimensions(VALUE self, VALUE data) {
234
245
  const char *oldPNG = StringValuePtr(data);
235
246
  size_t oldPNG_length = RSTRING_LEN(data);
@@ -260,6 +271,6 @@ static VALUE ApplePng_get_dimensions(VALUE self, VALUE data) {
260
271
 
261
272
  void Init_apple_png(void) {
262
273
  VALUE klass = rb_define_class("ApplePng", rb_cObject);
263
- rb_define_method(klass, "convert_apple_png", ApplePng_convert_apple_png, 1);
264
- rb_define_method(klass, "get_dimensions", ApplePng_get_dimensions, 1);
274
+ rb_define_protected_method(klass, "convert_apple_png", ApplePng_convert_apple_png, 1);
275
+ rb_define_protected_method(klass, "get_dimensions", ApplePng_get_dimensions, 1);
265
276
  }
data/lib/apple_png.rb CHANGED
@@ -3,14 +3,19 @@ require 'apple_png/apple_png'
3
3
  class ApplePng
4
4
  attr_accessor :width, :height
5
5
 
6
+ # Create a new ApplePng instance from Apple PNG data in a string
7
+ # @param apple_png_data [String] Binary string containing Apple PNG data, probably read from a file
6
8
  def initialize(apple_png_data)
7
9
  self.get_dimensions(apple_png_data)
8
10
  @raw_data = apple_png_data
9
11
  end
10
12
 
13
+ # Get the PNG data as string. The conversion from Apple PNG data to standard PNG data will be performed when this method is first called.
14
+ # @return [String] Binary string containing standard PNG data
11
15
  def data
12
16
  if @data.nil?
13
17
  @data = self.convert_apple_png(@raw_data)
18
+ @raw_data = nil
14
19
  end
15
20
  return @data
16
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple_png
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,3 +47,4 @@ signing_key:
47
47
  specification_version: 3
48
48
  summary: Converts the Apple PNG format to standard PNG
49
49
  test_files: []
50
+ has_rdoc: