Class: Gly::DocumentGabcConvertor

Inherits:
Object
  • Object
show all
Defined in:
lib/gly/document_gabc_convertor.rb

Instance Method Summary collapse

Constructor Details

#initialize(document, **options) ⇒ DocumentGabcConvertor

Returns a new instance of DocumentGabcConvertor.



3
4
5
6
# File 'lib/gly/document_gabc_convertor.rb', line 3

def initialize(document, **options)
  @doc = document
  @options = options
end

Instance Method Details

#convertObject



8
9
10
11
12
13
14
15
# File 'lib/gly/document_gabc_convertor.rb', line 8

def convert
  each_score_with_gabcname do |score, out_fname|
    File.open(out_fname, 'w') do |fw|
      GabcConvertor.new.convert score, fw
    end
    yield score, out_fname if block_given?
  end
end

#each_score_with_gabcnameObject

iterates over document scores, yields score and filename of it’s generated gabc file



19
20
21
22
23
24
25
26
27
# File 'lib/gly/document_gabc_convertor.rb', line 19

def each_score_with_gabcname
  return to_enum(:each_score_with_gabcname) unless block_given?

  @doc.scores.each_with_index do |score, si|
    gabc = gabc_fname(score, si)
    gtex = gtex_fname(score, si)
    yield score, gabc, gtex
  end
end