Class: Pslm::ConsoleOutputter::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/pslm/consoleoutputter.rb

Overview

abstract superclass of the formatters providing dumb implementation of all formatting methods

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Formatter

Returns a new instance of Formatter.



102
103
104
105
106
107
108
# File 'lib/pslm/consoleoutputter.rb', line 102

def initialize(options)
  @options = options
  @syll_counter = 0
  @word_counter = 0
  @part_counter = 0
  @verse_counter = 0
end

Class Method Details

.format(formatters, level, text, *args) ⇒ Object

lets all the :formatters: subsequently format :text: assembled from :obj: on the assembly :level:



94
95
96
97
98
99
# File 'lib/pslm/consoleoutputter.rb', line 94

def format(formatters, level, text, *args)
  formatters.each do |f|
    text = f.send("#{level}_format", text, *args)
  end
  return text
end

Instance Method Details

#part_format(text, part) ⇒ Object



126
127
128
129
130
131
# File 'lib/pslm/consoleoutputter.rb', line 126

def part_format(text, part)
  @part_counter += 1
  @syll_counter = 0
  @word_counter = 0
  text
end

#psalm_format(text, psalm) ⇒ Object



110
111
112
113
114
115
116
# File 'lib/pslm/consoleoutputter.rb', line 110

def psalm_format(text, psalm)
  @syll_counter = 0
  @word_counter = 0
  @part_counter = 0
  @verse_counter = 0
  text
end

#syllable_format(text, part, word, syll) ⇒ Object



138
139
140
141
# File 'lib/pslm/consoleoutputter.rb', line 138

def syllable_format(text, part, word, syll)
  @syll_counter += 1
  text
end

#verse_format(text, psalm, verse) ⇒ Object



118
119
120
121
122
123
124
# File 'lib/pslm/consoleoutputter.rb', line 118

def verse_format(text, psalm, verse)
  @verse_counter += 1
  @syll_counter = 0
  @word_counter = 0
  @part_counter = 0
  text
end

#word_format(text, word) ⇒ Object



133
134
135
136
# File 'lib/pslm/consoleoutputter.rb', line 133

def word_format(text, word)
  @word_counter += 1
  text
end