class Plugin::Skin::Image

Public Class Methods

[](path) click to toggle source
# File core/plugin/skin/model/image.rb, line 10
def self.[](path)
  @store ||= Hash.new{|h,k| h[k] = new(path: k) } # path => Image
  @store[path]
end

Public Instance Methods

pixbuf(width:, height:) click to toggle source

引数の寸法の GdkPixbuf::Pixbuf を返す。

Args

width:

Pixbufの幅(px)

height:

Pixbufの高さ(px)

Return

GdkPixbuf::Pixbuf

メモリキャッシュやファイルシステムから画像が見つかった場合

# File core/plugin/skin/model/image.rb, line 25
def pixbuf(width,, height))
  result = pixbuf_cache[[width, height].hash]
  if result
    result.pixbuf
  else
    pixbuf_cache_set(GdkPixbuf::Pixbuf.new(file: uri.path, width: width, height: height), width: width, height: height)
  end
end
uri() click to toggle source
# File core/plugin/skin/model/image.rb, line 15
        def uri
  Diva::URI.new(scheme: 'file'.freeze, path: path)
end