Class: Pslm::ConsoleOutputter::PointingFormatter
- Defined in:
- lib/pslm/consoleoutputter.rb
Overview
marks accentuated and preparatory syllables
Constant Summary collapse
- MARKS =
{ :underline => {:color => :blue, :mode => :underline}, :bold => {:color => :blue, :mode => :bold}, :semantic => {:color => :blue, :mode => :bold} }
Instance Method Summary collapse
-
#initialize(options) ⇒ PointingFormatter
constructor
A new instance of PointingFormatter.
- #part_format(text, part) ⇒ Object
- #syllable_format(text, part, word, syll) ⇒ Object
Methods inherited from Formatter
format, #psalm_format, #verse_format, #word_format
Constructor Details
#initialize(options) ⇒ PointingFormatter
Returns a new instance of PointingFormatter.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/pslm/consoleoutputter.rb', line 146 def initialize() super() @accent_counter = 0 @preparatories_counter = 0 # validate options if .has_key? :tone and (.has_key? :accents or .has_key? :preparatory) then raise RuntimeError.new('Overconfigured: both accents/preparatories number and psalm tone specified.') elsif .has_key? :accents then # ok, nothing to do elsif .has_key? :tone # convert psalm tone identifier to numbers tone = PsalmPatterns.default.tone_data_str([:tone]) [:accents] = tone.collect {|part| part[0] } [:preparatory] = tone.collect {|part| part[1] } end if [:accent_style] != nil then if MARKS.has_key? [:accent_style] then @accent_style = MARKS[[:accent_style]] else # user_defined style @accent_style = [:accent_style].to_sym end else @accent_style = :blue end @preparatory_style = :magenta end |
Instance Method Details
#part_format(text, part) ⇒ Object
178 179 180 181 182 183 |
# File 'lib/pslm/consoleoutputter.rb', line 178 def part_format(text, part) super(text, part) @accent_counter = 0 @preparatories_counter = 0 text end |
#syllable_format(text, part, word, syll) ⇒ Object
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/pslm/consoleoutputter.rb', line 191 def syllable_format(text, part, word, syll) super(text, part, word, syll) r = text if syll.accent? then @accent_counter += 1 if @accent_counter <= num_accents_for(part) then r = r.colorize @accent_style end end if num_preparatory_syllables_for(part) > 0 and @accent_counter >= num_accents_for(part) then if @preparatories_counter >= 1 and @preparatories_counter <= num_preparatory_syllables_for(part) then r = r.colorize @preparatory_style end @preparatories_counter += 1 end return r end |