Class: Exerb::Resource::Icon

Inherits:
Base
  • Object
show all
Defined in:
lib/exerb/resource/icon.rb

Overview

#

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#size

Constructor Details

#initializeIcon

Returns a new instance of Icon.



21
22
23
24
25
26
27
# File 'lib/exerb/resource/icon.rb', line 21

def initialize
  super()
  @width     = nil
  @height    = nil
  @bit_count = nil
  @value     = nil
end

Instance Attribute Details

#bit_countObject

Returns the value of attribute bit_count.



29
30
31
# File 'lib/exerb/resource/icon.rb', line 29

def bit_count
  @bit_count
end

#heightObject

Returns the value of attribute height.



29
30
31
# File 'lib/exerb/resource/icon.rb', line 29

def height
  @height
end

#valueObject

Returns the value of attribute value.



29
30
31
# File 'lib/exerb/resource/icon.rb', line 29

def value
  @value
end

#widthObject

Returns the value of attribute width.



29
30
31
# File 'lib/exerb/resource/icon.rb', line 29

def width
  @width
end

Class Method Details

.read(input, width, height, bit_count) ⇒ Object

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/exerb/resource/icon.rb', line 31

def self.read(input, width, height, bit_count)
  icon_file  = Exerb::Win32::IconFile.read(input)
  icon_entry = icon_file.entries.find { |entry| entry.width == width && entry.height == height && entry.bit_count == bit_count }
  raise(Exerb::ExerbError, "no such icon #{width}x#{height}x#{bit_count} in #{input}") unless icon_entry

  icon = self.new
  icon.width     = icon_entry.width
  icon.height    = icon_entry.height
  icon.bit_count = icon_entry.bit_count
  icon.value     = icon_entry.value

  return icon
end

Instance Method Details

#packObject



45
46
47
# File 'lib/exerb/resource/icon.rb', line 45

def pack
  return @value
end