Class: VR::IconHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/IconHash.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(path, width = nil, height = nil) ⇒ IconHash

Returns a new instance of IconHash.



5
6
7
8
9
10
11
12
13
14
# File 'lib/IconHash.rb', line 5

def initialize(path,width=nil,height=nil)
  Dir.glob(path + "/*.png").each do |f|
    ext = File.basename(f, ".png")
    if width.nil?
      self[ext] = Gdk::Pixbuf.new(f)
    else
      self[ext] = Gdk::Pixbuf.new(f,width,height)
    end
  end
end

Instance Method Details

#get_icon(file_name) ⇒ Object



16
17
18
19
# File 'lib/IconHash.rb', line 16

def get_icon(file_name)
  ext = File.extname(file_name).gsub(".", "")
  self.has_key?(ext) ? self[ext] : self["unknown"] 
end