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
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#path ⇒ Object
Returns the value of attribute path.
-
#scores ⇒ Object
readonly
Returns the value of attribute scores.
Instance Method Summary collapse
- #<<(score) ⇒ Object
- #[](key) ⇒ Object
-
#initialize ⇒ Document
constructor
A new instance of Document.
Constructor Details
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
13 14 15 |
# File 'lib/gly/document.rb', line 13 def header @header end |
#path ⇒ Object
Returns the value of attribute path.
14 15 16 |
# File 'lib/gly/document.rb', line 14 def path @path end |
#scores ⇒ Object (readonly)
Returns the value of attribute scores.
13 14 15 |
# File 'lib/gly/document.rb', line 13 def scores @scores end |
Instance Method Details
#<<(score) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gly/document.rb', line 16 def <<(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 self end |
#[](key) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/gly/document.rb', line 31 def [](key) if key.is_a? Integer @scores[key] else @scores_by_id[key] end end |