Class: Gly::Headers
- Inherits:
-
Object
- Object
- Gly::Headers
- Extended by:
- Forwardable
- Defined in:
- lib/gly/headers.rb
Overview
score or document header
Constant Summary collapse
- GREGORIO_HEADERS =
header fields supported by gregorio. Based on gregorio-project.github.io/gabc/index.html#header last checked 2015-12-06
%w( name gabc-copyright score-copyright office-part occasion meter commentary arranger gabc-version author date manuscript manuscript-reference manuscript-storage-place book transcriber transcription-date gregoriotex-font mode initial-style centering-scheme user-notes annotation nabc-lines )
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #each_pair ⇒ Object
-
#each_value(key) ⇒ Object
some header fields may appear more than once; this method provides access to values of all occurrences of a given header field.
- #headers ⇒ Object
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
38 39 40 41 42 43 44 |
# File 'lib/gly/headers.rb', line 38 def initialize # for quick lookup. Only holds a single value per header @headers = {} # holds order and as many values for a header as given in the # score (typically annotation occurs more than once) @pairs = [] end |
Class Method Details
.gregorio_supported?(key) ⇒ Boolean
74 75 76 |
# File 'lib/gly/headers.rb', line 74 def self.gregorio_supported?(key) GREGORIO_HEADERS.include? key end |
Instance Method Details
#[]=(key, value) ⇒ Object
46 47 48 49 |
# File 'lib/gly/headers.rb', line 46 def []=(key, value) @headers[key] = value @pairs << [key, value] end |
#each_pair ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/gly/headers.rb', line 66 def each_pair return to_enum(:each_pair) unless block_given? @pairs.each do |k| yield k[0], k[1] end end |
#each_value(key) ⇒ Object
some header fields may appear more than once; this method provides access to values of all occurrences of a given header field
58 59 60 61 62 63 64 |
# File 'lib/gly/headers.rb', line 58 def each_value(key) return to_enum(:each_value, key) unless block_given? each_pair do |k,v| yield v if k == key end end |
#headers ⇒ Object
78 79 80 |
# File 'lib/gly/headers.rb', line 78 def headers self end |