class Bohne::Bohne
Public Class Methods
convert(source, destination)
click to toggle source
# File lib/bohne.rb, line 6 def self.convert(source, destination) input = Bohne.new(source) input.write(destination) end
new(path)
click to toggle source
# File lib/bohne.rb, line 11 def initialize(path) @doc = doc = REXML::Document.new(File.new(path)) document = doc.elements['document'] document.attributes['targetRuntime'] = 'AppleTV' document.attributes['type'] = 'com.apple.InterfaceBuilder.AppleTV.XIB' document.attributes['useTraitCollections'] = nil document.elements['dependencies'].elements['deployment'].remove rootView = document.elements['objects'].elements['view'] rootViewRect = rootView.elements['rect'] rootViewRect.attributes['width'] = '1920' rootViewRect.attributes['height'] = '1080' end
Public Instance Methods
to_s()
click to toggle source
# File lib/bohne.rb, line 28 def to_s formatter = REXML::Formatters::Pretty.new(2) formatter.compact = false out = '' formatter.write(@doc, out) out.gsub!("<?xml version='1.0' encoding='UTF-8'?>", '<?xml version="1.0" encoding="UTF-8"?>') out.gsub!("'", '"') out << "\n" out end
write(path)
click to toggle source
# File lib/bohne.rb, line 39 def write(path) File.open(path, 'w') do |f| f.write(to_s) end end