Class: Xcplayground::Playground

Inherits:
Object
  • Object
show all
Defined in:
lib/xcplayground/playground.rb

Overview

Represents a .playground file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, platform = :ios) ⇒ Playground

Returns a new instance of Playground.



10
11
12
13
14
15
16
# 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

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/xcplayground/playground.rb', line 8

def path
  @path
end

#playground_fileObject (readonly)

Returns the value of attribute playground_file.



8
9
10
# File 'lib/xcplayground/playground.rb', line 8

def playground_file
  @playground_file
end

#source_filesObject

Returns the value of attribute source_files.



7
8
9
# File 'lib/xcplayground/playground.rb', line 7

def source_files
  @source_files
end

#swift_fileObject (readonly)

Returns the value of attribute swift_file.



8
9
10
# File 'lib/xcplayground/playground.rb', line 8

def swift_file
  @swift_file
end

#timeline_fileObject (readonly)

Returns the value of attribute timeline_file.



8
9
10
# File 'lib/xcplayground/playground.rb', line 8

def timeline_file
  @timeline_file
end

Instance Method Details

#saveObject



18
19
20
21
22
23
24
25
26
27
# 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