Class: XCDM::Schema
- Inherits:
-
Object
- Object
- XCDM::Schema
- Defined in:
- lib/xcdm/schema.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#xcode_version ⇒ Object
readonly
Returns the value of attribute xcode_version.
Instance Method Summary collapse
- #entity(name, options = {}, &block) ⇒ Object
-
#initialize(version, xcode_version) ⇒ Schema
constructor
A new instance of Schema.
- #to_xml(builder = nil) ⇒ Object
Constructor Details
#initialize(version, xcode_version) ⇒ Schema
Returns a new instance of Schema.
12 13 14 15 16 |
# File 'lib/xcdm/schema.rb', line 12 def initialize(version, xcode_version) @version = version @xcode_version = xcode_version @entities = [] end |
Instance Attribute Details
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
10 11 12 |
# File 'lib/xcdm/schema.rb', line 10 def entities @entities end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
10 11 12 |
# File 'lib/xcdm/schema.rb', line 10 def version @version end |
#xcode_version ⇒ Object (readonly)
Returns the value of attribute xcode_version.
10 11 12 |
# File 'lib/xcdm/schema.rb', line 10 def xcode_version @xcode_version end |
Instance Method Details
#entity(name, options = {}, &block) ⇒ Object
18 19 20 |
# File 'lib/xcdm/schema.rb', line 18 def entity(name, = {}, &block) @entities << Entity.new(self, name, ).tap { |e| e.instance_eval(&block) } end |
#to_xml(builder = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/xcdm/schema.rb', line 22 def to_xml(builder = nil) builder ||= Builder::XmlMarkup.new(:indent => 2) builder.instruct! :xml, :standalone => 'yes' if xcode_version =~ /5\.x/ attrs = { name: "", userDefinedModelVersionIdentifier: version, type: "com.apple.IDECoreDataModeler.DataModel", documentVersion: "1.0", lastSavedToolsVersion: "3389", systemVersion: "12E55", minimumToolsVersion: "Xcode 5", macOSVersion: "Automatic", iOSVersion: "Automatic" } else attrs = { name: "", userDefinedModelVersionIdentifier: version, type: "com.apple.IDECoreDataModeler.DataModel", documentVersion: "1.0", lastSavedToolsVersion: "2061", systemVersion: "12D78", minimumToolsVersion: "Xcode 4.3", macOSVersion: "Automatic", iOSVersion: "Automatic" } end builder.model(attrs) do |builder| entities.each do |entity| entity.to_xml(builder) end end end |