Class: Rabbit::ImageDataLoader
- Inherits:
-
Object
- Object
- Rabbit::ImageDataLoader
- Defined in:
- lib/rabbit/image-data-loader.rb
Instance Attribute Summary collapse
-
#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.
22 23 24 25 26 27 |
# File 'lib/rabbit/image-data-loader.rb', line 22 def initialize(data) @width = 0 @height = 0 @pixbuf = nil @data = data end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
21 22 23 |
# File 'lib/rabbit/image-data-loader.rb', line 21 def height @height end |
#pixbuf ⇒ Object (readonly)
Returns the value of attribute pixbuf.
21 22 23 |
# File 'lib/rabbit/image-data-loader.rb', line 21 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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rabbit/image-data-loader.rb', line 29 def load loader = Gdk::PixbufLoader.new id = loader.signal_connect("size_prepared") do |l, width, height| @width = width @height = height end begin loader.last_write(@data) rescue Gdk::PixbufError => error loader.close rescue Gdk::PixbufError raise ImageLoadError.new(error.) end loader.signal_handler_disconnect(id) @pixbuf = loader.pixbuf @pixbuf end |