Class: Xcplayground::XcplaygroundFile
- Inherits:
-
Object
- Object
- Xcplayground::XcplaygroundFile
- Defined in:
- lib/xcplayground/xcplayground_file.rb
Overview
Represent a Swift language file on disc
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(platform, fname = 'contents.xcplayground', version = '5.0') ⇒ XcplaygroundFile
constructor
A new instance of XcplaygroundFile.
- #save(path, timeline_file = 'timeline.xctimeline') ⇒ Object
- #to_s(timeline_file) ⇒ Object
Constructor Details
#initialize(platform, fname = 'contents.xcplayground', version = '5.0') ⇒ XcplaygroundFile
Returns a new instance of XcplaygroundFile.
10 11 12 13 14 |
# File 'lib/xcplayground/xcplayground_file.rb', line 10 def initialize(platform, fname = 'contents.xcplayground', version = '5.0') @platform = platform @filename = fname @version = version end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
8 9 10 |
# File 'lib/xcplayground/xcplayground_file.rb', line 8 def filename @filename end |
#platform ⇒ Object
Returns the value of attribute platform.
7 8 9 |
# File 'lib/xcplayground/xcplayground_file.rb', line 7 def platform @platform end |
#version ⇒ Object
Returns the value of attribute version.
6 7 8 |
# File 'lib/xcplayground/xcplayground_file.rb', line 6 def version @version end |
Instance Method Details
#save(path, timeline_file = 'timeline.xctimeline') ⇒ Object
16 17 18 19 20 21 |
# File 'lib/xcplayground/xcplayground_file.rb', line 16 def save(path, timeline_file = 'timeline.xctimeline') file = File.join(path, filename) File.open(file, 'w') do |f| f.puts to_s(timeline_file) end end |
#to_s(timeline_file) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/xcplayground/xcplayground_file.rb', line 23 def to_s(timeline_file) xml = Builder::XmlMarkup.new(indent: 2) xml.instruct! :xml, version: '1.0', encoding: 'UTF-8', standalone: 'yes' xml.playground(version: version, 'target-platform' => platform) do |p| p.timeline(fileName: timeline_file) end xml.target! end |