Class: MusicalScore::Score::Identification::Creator
- Inherits:
-
ElementBase
- Object
- ElementBase
- MusicalScore::Score::Identification::Creator
- Includes:
- Contracts
- Defined in:
- lib/musical_score/score/identification/creator.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #export_xml ⇒ Object
-
#initialize(name, type) ⇒ Creator
constructor
A new instance of Creator.
Constructor Details
#initialize(name, type) ⇒ Creator
Returns a new instance of Creator.
9 10 11 12 |
# File 'lib/musical_score/score/identification/creator.rb', line 9 def initialize(name, type) @name = name @type = type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/musical_score/score/identification/creator.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/musical_score/score/identification/creator.rb', line 6 def type @type end |
Class Method Details
.create_by_hash(doc) ⇒ Object
22 23 24 25 26 |
# File 'lib/musical_score/score/identification/creator.rb', line 22 def self.create_by_hash(doc) type = doc["type"].to_sym name = doc["content"] return MusicalScore::Score::Identification::Creator.new(name, type) end |
.create_by_xml(xml_doc) ⇒ Object
15 16 17 18 19 |
# File 'lib/musical_score/score/identification/creator.rb', line 15 def self.create_by_xml(xml_doc) type = xml_doc.attributes["type"].to_sym name = xml_doc.text return MusicalScore::Score::Identification::Creator.new(name, type) end |
Instance Method Details
#export_xml ⇒ Object
28 29 30 31 32 33 |
# File 'lib/musical_score/score/identification/creator.rb', line 28 def export_xml creator = REXML::Element.new('creator') creator.add_attribute('type', @type) creator.add_text(@name) return creator end |