Class: Rabbit::ImageDataLoader
- Inherits:
-
Object
- Object
- Rabbit::ImageDataLoader
- Defined in:
- lib/rabbit/image-data-loader.rb
Instance Attribute Summary collapse
-
#animation ⇒ Object
readonly
Returns the value of attribute animation.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#pixbuf ⇒ Object
readonly
Returns the value of attribute pixbuf.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(data) ⇒ ImageDataLoader
constructor
A new instance of ImageDataLoader.
- #load ⇒ Object
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
#animation ⇒ Object (readonly)
Returns the value of attribute animation.
24 25 26 |
# File 'lib/rabbit/image-data-loader.rb', line 24 def animation @animation end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
22 23 24 |
# File 'lib/rabbit/image-data-loader.rb', line 22 def height @height end |
#pixbuf ⇒ Object (readonly)
Returns the value of attribute pixbuf.
23 24 25 |
# File 'lib/rabbit/image-data-loader.rb', line 23 def pixbuf @pixbuf end |
#width ⇒ Object (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
#load ⇒ Object
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.) end loader.signal_handler_disconnect(id) @pixbuf = loader.pixbuf @animation = loader.animation @pixbuf end |