Class: Rabbit::ImageDataLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/rabbit/image-data-loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ImageDataLoader

Returns a new instance of ImageDataLoader.



25
26
27
28
29
30
31
# File 'lib/rabbit/image-data-loader.rb', line 25

def initialize(data)
  @width = 0
  @height = 0
  @pixbuf = nil
  @animation = nil
  @data = data
end

Instance Attribute Details

#animationObject (readonly)

Returns the value of attribute animation.



24
25
26
# File 'lib/rabbit/image-data-loader.rb', line 24

def animation
  @animation
end

#heightObject (readonly)

Returns the value of attribute height.



22
23
24
# File 'lib/rabbit/image-data-loader.rb', line 22

def height
  @height
end

#pixbufObject (readonly)

Returns the value of attribute pixbuf.



23
24
25
# File 'lib/rabbit/image-data-loader.rb', line 23

def pixbuf
  @pixbuf
end

#widthObject (readonly)

Returns the value of attribute width.



21
22
23
# File 'lib/rabbit/image-data-loader.rb', line 21

def width
  @width
end

Instance Method Details

#loadObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rabbit/image-data-loader.rb', line 33

def load
  loader = GdkPixbuf::PixbufLoader.new
  id = loader.signal_connect("size_prepared") do |l, width, height|
    @width = width
    @height = height
  end
  begin
    loader.last_write(@data)
  rescue GdkPixbuf::PixbufError => error
    loader.close rescue GdkPixbuf::PixbufError
    raise ImageLoadError.new(error.message)
  end
  loader.signal_handler_disconnect(id)
  @pixbuf = loader.pixbuf
  @animation = loader.animation
  @pixbuf
end