Class: PSD::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/psd/resource.rb,
lib/psd/resources/base.rb,
lib/psd/resource_section.rb,
lib/psd/resources/guides.rb,
lib/psd/resources/slices.rb,
lib/psd/resources/work_path.rb,
lib/psd/resources/saved_path.rb,
lib/psd/resources/layer_comps.rb,
lib/psd/resources/xmp_metadata.rb,
lib/psd/resources/resolution_info.rb

Overview

Definition for a single Resource record.

Most of the resources are options/preferences set by the user or automatically by Photoshop.

Defined Under Namespace

Modules: Section

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Resource

Returns a new instance of Resource.



10
11
12
13
14
# File 'lib/psd/resource.rb', line 10

def initialize(file)
  @file = file
  @data = {}
  @type = nil
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



8
9
10
# File 'lib/psd/resource.rb', line 8

def data
  @data
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/psd/resource.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/psd/resource.rb', line 7

def name
  @name
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/psd/resource.rb', line 7

def size
  @size
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/psd/resource.rb', line 7

def type
  @type
end

Instance Method Details

#parseObject



16
17
18
19
20
21
22
23
24
# File 'lib/psd/resource.rb', line 16

def parse
  @type = @file.read_string(4) # Always 8BIM
  @id = @file.read_short

  name_length = Util.pad2(@file.read(1).bytes.to_a[0] + 1) - 1
  @name = @file.read_string(name_length)

  @size = Util.pad2(@file.read_int)
end