Class: Pslm::PslmOutputter

Inherits:
Outputter show all
Defined in:
lib/pslm/pslmoutputter.rb

Overview

reconstructs the input format

an easier implementation would make use of VersePart#src, but this should be a simple example of full-depth output preparation

Constant Summary

Constants inherited from Outputter

Outputter::DEFAULT_SETUP

Instance Method Summary collapse

Instance Method Details

#part_format(text, part) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/pslm/pslmoutputter.rb', line 56

def part_format(text, part)
  case part.pos
  when :flex
    return text + ' +'
  when :first
    return text + ' *'
  else
    return text
  end
end

#process(psalm, options = {}) ⇒ Object

doesn’t respect any options; accepts them only because of a common outputter interface



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pslm/pslmoutputter.rb', line 13

def process(psalm, options={})
  psalm_assembled = psalm.verses.collect do |verse|

    verse_assembled = verse.parts.collect do |part|

      part_assembled = part.words.collect do |word|

        word_assembled = ''
        word.syllables.each_with_index do |syll, si|

          if word_assembled.size > 0 and
              not word.syllables[si-1].accent? and
              not syll.accent? then
            word_assembled += '/'
          end
          word_assembled += syllable_format(syll)
        end

        word_format word_assembled, word

      end.join ' '
      part_format part_assembled, part

    end.join "\n"
    verse_format verse_assembled, verse

  end.join "\n"

  return psalm.header.title + "\n\n" + psalm_assembled
end

#syllable_format(syll) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/pslm/pslmoutputter.rb', line 44

def syllable_format(syll)
  if syll.accent? then
    return '[' + syll + ']'
  end

  return syll
end

#verse_format(text, verse) ⇒ Object



67
68
69
# File 'lib/pslm/pslmoutputter.rb', line 67

def verse_format(text, verse)
  text
end

#word_format(text, word) ⇒ Object



52
53
54
# File 'lib/pslm/pslmoutputter.rb', line 52

def word_format(text, word)
  text
end