class Xcplayground::Playground

Represents a .playground file

Attributes

path[R]
playground_file[R]
source_files[RW]
swift_file[R]
timeline_file[R]

Public Class Methods

new(path, platform = :ios) click to toggle source
# File lib/xcplayground/playground.rb, line 10
def initialize(path, platform = :ios)
  @path = File.expand_path(path)
  @swift_file      = SwiftFile.new('contents.swift')
  @timeline_file   = XctimelineFile.new
  @playground_file = XcplaygroundFile.new(platform)
  @source_files    = [SwiftFile.new('SupportCode.swift')]
end

Public Instance Methods

save() click to toggle source
# File lib/xcplayground/playground.rb, line 18
def save
  # Make the playground container directory
  FileUtils.mkdir_p(path)

  # Save the timeline and playground files
  [timeline_file, playground_file, swift_file].each { |f| f.save(path) }

  # Save the additional source files
  save_sources
end

Private Instance Methods

save_sources() click to toggle source
# File lib/xcplayground/playground.rb, line 31
def save_sources
  source_path = File.join(path, 'Sources')
  FileUtils.mkdir_p(source_path)
  source_files.each { |f| f.save(source_path) }
end