class Xcplayground::XcplaygroundFile

Represent a Swift language file on disc

Attributes

filename[RW]
platform[RW]
version[RW]

Public Class Methods

new(platform, fname = 'contents.xcplayground', version = '5.0') click to toggle source
# File lib/xcplayground/xcplayground_file.rb, line 10
def initialize(platform, fname = 'contents.xcplayground', version = '5.0')
  @platform = platform
  @filename = fname
  @version  = version
end

Public Instance Methods

save(path, timeline_file = 'timeline.xctimeline') click to toggle source
# 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) click to toggle source
# 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