Class: Gly::Document
- Inherits:
-
Object
- Object
- Gly::Document
- Defined in:
- lib/gly/document.rb
Overview
Result of parsing of a gly file. Usually contains one or more scores and possibly a document header.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Scores and Markups.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scores ⇒ Object
readonly
only Scores.
Instance Method Summary collapse
-
#<<(score) ⇒ Object
append a new Score (or Markup).
- #[](key) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
Constructor Details
Instance Attribute Details
#content ⇒ Object (readonly)
Scores and Markups
18 19 20 |
# File 'lib/gly/document.rb', line 18 def content @content end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
20 21 22 |
# File 'lib/gly/document.rb', line 20 def header @header end |
#path ⇒ Object
Returns the value of attribute path.
21 22 23 |
# File 'lib/gly/document.rb', line 21 def path @path end |
#scores ⇒ Object (readonly)
only Scores
15 16 17 |
# File 'lib/gly/document.rb', line 15 def scores @scores end |
Instance Method Details
#<<(score) ⇒ Object
append a new Score (or Markup)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gly/document.rb', line 24 def <<(score) @content << score if score.is_a? Score @scores << score sid = score.headers['id'] if sid if @scores_by_id.has_key? sid raise ArgumentError.new("More than one score with id '#{sid}'.") end @scores_by_id[sid] = score end end self end |
#[](key) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/gly/document.rb', line 43 def [](key) if key.is_a? Integer @scores[key] else @scores_by_id[key] end end |