Class: CoreData::DataModel
- Inherits:
-
Object
- Object
- CoreData::DataModel
- Defined in:
- lib/core_data/data_model.rb
Instance Attribute Summary collapse
-
#entities ⇒ Object
readonly
Returns the value of attribute entities.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(xcdatamodel) ⇒ DataModel
constructor
A new instance of DataModel.
Constructor Details
#initialize(xcdatamodel) ⇒ DataModel
Returns a new instance of DataModel.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/core_data/data_model.rb', line 5 def initialize(xcdatamodel) loop do case xcdatamodel when File, /^\<\?xml/ xcdatamodel = ::Nokogiri::XML(xcdatamodel) and redo when String xcdatamodel = ::File.read(xcdatamodel) and redo when ::Nokogiri::XML::Document break else raise ArgumentError end end model = xcdatamodel.at_xpath('model') @name = model['name'] @version = model['systemVersion'] @entities = model.xpath('entity').collect{|element| Entity.new(element)} end |
Instance Attribute Details
#entities ⇒ Object (readonly)
Returns the value of attribute entities.
3 4 5 |
# File 'lib/core_data/data_model.rb', line 3 def entities @entities end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/core_data/data_model.rb', line 3 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/core_data/data_model.rb', line 3 def version @version end |