Method: PSD::Resource::Section.factory

Defined in:
lib/psd/resource_section.rb

.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