Sha256: 35119b796312a64538667bef3d6339f4f706d46fa5cdcfa95c07e86e451f25aa
Contents?: true
Size: 1.14 KB
Versions: 6
Compression:
Stored size: 1.14 KB
Contents
require 'xcres/model/xcassets/resource' module XCRes::XCAssets # Represents the whole asset catalog # class Bundle # @return [Pathname] # attr_accessor :path # @return [Array<Pathname>] # the paths of the resources contained, relative to the container # given by #path. attr_accessor :resource_paths # @return [Array<Resource>] # the parsed resources attr_accessor :resources # Open a XCAssets collection at a given path # # @return [XCAssets::Bundle] # def self.open(path) self.new(path).read end # Initialize a new file with given path # # @param [Pathname] path # the location of the container # def initialize(path = nil) @path = Pathname(path) unless path.nil? @resources = [] end # Read the resources from disk # # @return [XCAssets::Bundle] # 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 end end
Version data entries
6 entries across 6 versions & 1 rubygems