Class: MusicalScore::Score::Identification::Identification
- Inherits:
-
ElementBase
- Object
- ElementBase
- MusicalScore::Score::Identification::Identification
- Includes:
- Contracts
- Defined in:
- lib/musical_score/score/identification/identification.rb
Instance Attribute Summary collapse
-
#creators ⇒ Object
readonly
Returns the value of attribute creators.
-
#encoding ⇒ Object
readonly
Returns the value of attribute encoding.
Class Method Summary collapse
Instance Method Summary collapse
- #export_xml ⇒ Object
-
#initialize(creators, encodings) ⇒ Identification
constructor
A new instance of Identification.
Constructor Details
#initialize(creators, encodings) ⇒ Identification
Returns a new instance of Identification.
15 16 17 18 |
# File 'lib/musical_score/score/identification/identification.rb', line 15 def initialize(creators, encodings) @creators = creators @encoding = encodings end |
Instance Attribute Details
#creators ⇒ Object (readonly)
Returns the value of attribute creators.
13 14 15 |
# File 'lib/musical_score/score/identification/identification.rb', line 13 def creators @creators end |
#encoding ⇒ Object (readonly)
Returns the value of attribute encoding.
13 14 15 |
# File 'lib/musical_score/score/identification/identification.rb', line 13 def encoding @encoding end |
Class Method Details
.create_by_hash(doc) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/musical_score/score/identification/identification.rb', line 36 def self.create_by_hash(doc) creators = Array.new if (doc.has_key?("creator")) doc["creator"].each do |element| creators.push(MusicalScore::Score::Identification::Creator.create_by_hash(element)) end end encoding = doc.has_key?("encoding") ? MusicalScore::Score::Identification::Encoding.create_by_hash(doc["encoding"][0]) : nil return MusicalScore::Score::Identification::Identification.new(creators, encoding) end |
.create_by_xml(xml_doc) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/musical_score/score/identification/identification.rb', line 21 def self.create_by_xml(xml_doc) creator_doc = xml_doc.elements["//creator"] encoding_doc = xml_doc.elements["//encoding"] creators = Array.new xml_doc.elements.each("//creator") do |element| creators.push(MusicalScore::Score::Identification::Creator.create_by_xml(element)) end encoding = encoding_doc ? MusicalScore::Score::Identification::Encoding.create_by_xml(encoding_doc) : nil return MusicalScore::Score::Identification::Identification.new(creators, encoding) end |
Instance Method Details
#export_xml ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/musical_score/score/identification/identification.rb', line 47 def export_xml identification = REXML::Element.new('identification') @creators.each do |creator| identification.add_element(creator.export_xml) end identification.add_element(@encoding.export_xml) return identification end |