Module: PSD::Resource::Section

Defined in:
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

Defined Under Namespace

Classes: Base, Guides, LayerComps, ResolutionInfo, SavedPath, Slices, WorkPath, XMPMetadata

Class Method Summary collapse

Class Method Details

.factory(file, resource) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/psd/resource_section.rb', line 4

def self.factory(file, resource)
  if path_resource?(resource)
    section = Section::SavedPath.new(file, resource)
    section.parse
    return section.name
  end

  Section.constants.each do |c|
    next if c == :Base

    section = Section.const_get(c)
    next unless section.resource_id == resource.id

    section.new(file, resource).parse
    return section.name
  end

  return nil
end

.path_resource?(resource) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/psd/resource_section.rb', line 24

def self.path_resource?(resource)
  resource.id >= 2000 && resource.id <= 2997
end