Class: Xcplayground::XctimelineFile

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

Overview

Represent a .xctimeline file on disc

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename = 'timeline.xctimeline', version = '3.0') ⇒ XctimelineFile

Returns a new instance of XctimelineFile.



9
10
11
12
# File 'lib/xcplayground/xctimeline_file.rb', line 9

def initialize(filename = 'timeline.xctimeline', version = '3.0')
  @filename = filename
  @version  = version
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



6
7
8
# File 'lib/xcplayground/xctimeline_file.rb', line 6

def filename
  @filename
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#save(path) ⇒ Object



14
15
16
17
18
19
# File 'lib/xcplayground/xctimeline_file.rb', line 14

def save(path)
  file = File.join(path, filename)
  File.open(file, 'w') do |f|
    f.puts to_s
  end
end

#to_sObject



21
22
23
24
25
26
27
28
# File 'lib/xcplayground/xctimeline_file.rb', line 21

def to_s
  xml = Builder::XmlMarkup.new(indent: 2)
  xml.instruct! :xml, version: '1.0', encoding: 'UTF-8'
  xml.Timeline(version: version) do |tl|
    tl.TimelineItems {}
  end
  xml.target!
end