Class: XCRes::XCAssets::Bundle
- Inherits:
-
Object
- Object
- XCRes::XCAssets::Bundle
- Defined in:
- lib/xcres/model/xcassets/bundle.rb
Overview
Represents the whole asset catalog
Instance Attribute Summary collapse
- #path ⇒ Pathname
-
#resource_paths ⇒ Array<Pathname>
The paths of the resources contained, relative to the container given by #path.
-
#resources ⇒ Array<Resource>
The parsed resources.
Class Method Summary collapse
-
.open(path) ⇒ XCAssets::Bundle
Open a XCAssets collection at a given path.
Instance Method Summary collapse
-
#initialize(path = nil) ⇒ Bundle
constructor
Initialize a new file with given path.
-
#read ⇒ XCAssets::Bundle
Read the resources from disk.
Constructor Details
#initialize(path = nil) ⇒ Bundle
Initialize a new file with given path
35 36 37 38 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 35 def initialize(path = nil) @path = Pathname(path) unless path.nil? @resources = [] end |
Instance Attribute Details
#path ⇒ Pathname
11 12 13 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 11 def path @path end |
#resource_paths ⇒ Array<Pathname>
Returns the paths of the resources contained, relative to the container given by #path.
16 17 18 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 16 def resource_paths @resource_paths end |
#resources ⇒ Array<Resource>
Returns the parsed resources.
20 21 22 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 20 def resources @resources end |
Class Method Details
.open(path) ⇒ XCAssets::Bundle
Open a XCAssets collection at a given path
26 27 28 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 26 def self.open(path) self.new(path).read end |
Instance Method Details
#read ⇒ XCAssets::Bundle
Read the resources from disk
44 45 46 47 48 49 50 51 52 |
# File 'lib/xcres/model/xcassets/bundle.rb', line 44 def read @resource_paths = Dir.chdir(path) do Dir['**/Contents.json'].map { |p| Pathname(p) + '..' } end @resources = @resource_paths.map do |path| Resource.new(self, path) end self end |