Sha256: cdf85fcd7cf8d28aa4bb254c04b2761ee01e8c2008ca617d14c7a0284fa4a764
Contents?: true
Size: 1.22 KB
Versions: 24
Compression:
Stored size: 1.22 KB
Contents
class PSD # Parses and reads all of the Resource records in the document. class Resources include Section attr_reader :resources alias :data :resources def initialize(file) @file = file @resources = {} @type_index = {} @length = nil end # Parses each Resource and stores them. def parse start_section n = length start = @file.tell while n > 0 pos = @file.tell resource = Resource.new(@file) resource.parse resource_end = @file.tell + resource.size name = Resource::Section.factory(@file, resource) @resources[resource.id] = resource @type_index[name] = resource.id unless name.nil? @file.seek resource_end n -= @file.tell - pos end unless n == 0 @file.seek start + length end end_section end def skip @file.seek length, IO::SEEK_CUR end def [](id) if id.is_a?(Symbol) by_type(id) else @resources[id] end end def by_type(id) @resources[@type_index[id]] end private def length return @length unless @length.nil? @length = @file.read_int end end end
Version data entries
24 entries across 24 versions & 2 rubygems