Class: XCAssets::Iconset
- Inherits:
-
Object
- Object
- XCAssets::Iconset
- Defined in:
- lib/xcassets/iconset.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #add(image) ⇒ Object
- #contents ⇒ Object
- #info ⇒ Object
-
#initialize(name, author: 'xcassets', version: 1) ⇒ Iconset
constructor
A new instance of Iconset.
- #save(parent_path) ⇒ Object
Constructor Details
#initialize(name, author: 'xcassets', version: 1) ⇒ Iconset
Returns a new instance of Iconset.
9 10 11 12 13 14 |
# File 'lib/xcassets/iconset.rb', line 9 def initialize(name, author: 'xcassets', version: 1) @name = name @images = [] @author = @version = version end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
7 8 9 |
# File 'lib/xcassets/iconset.rb', line 7 def @author end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
7 8 9 |
# File 'lib/xcassets/iconset.rb', line 7 def images @images end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/xcassets/iconset.rb', line 7 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'lib/xcassets/iconset.rb', line 7 def version @version end |
Instance Method Details
#add(image) ⇒ Object
26 27 28 |
# File 'lib/xcassets/iconset.rb', line 26 def add(image) @images << image end |
#contents ⇒ Object
20 21 22 23 24 |
# File 'lib/xcassets/iconset.rb', line 20 def contents @images.each_with_object(info: info, images: []) do |image, hash| hash[:images] << image.contents end end |
#info ⇒ Object
16 17 18 |
# File 'lib/xcassets/iconset.rb', line 16 def info { author: @author, version: @version } end |
#save(parent_path) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/xcassets/iconset.rb', line 30 def save(parent_path) path = File.join(parent_path, "#{name}.iconset") Dir.mkdir(path) @images.each do |image| image.save(path) end json_path = File.join(path, 'Contents.json') File.open(json_path, 'w') do |file| JSON.dump(contents, file) end end |