Module: Lexdrill::LineFormatter
- Defined in:
- lib/lexdrill/line_formatter.rb
Overview
Formats a shown word for display. In "simple" mode: the drill sign (in blue), a space, then the word (colored by its show count, blue -> red as it's drilled more), all on one line. In "full" mode (the default): "counter/totalSEPARATOR\nword" — counter is the word's own 1-based position in the list, re-derived through Lexdrill::Beat so it stays meaningful even when a rhythm repeats steps.
Constant Summary collapse
- SEPARATOR =
"⟳"
Class Method Summary collapse
Class Method Details
.format(word) ⇒ Object
12 13 14 15 16 |
# File 'lib/lexdrill/line_formatter.rb', line 12 def self.format(word) return simple(word) if Lexdrill::Format.simple? full(word) end |
.full(word) ⇒ Object
23 24 25 26 27 |
# File 'lib/lexdrill/line_formatter.rb', line 23 def self.full(word) total = Lexdrill::WordList.words.size info = loop_info(total) "#{info.index + 1}/#{total}#{SEPARATOR}[#{info.chunk_start}-#{info.chunk_end}]\n#{word}" end |
.loop_info(total) ⇒ Object
29 30 31 32 33 |
# File 'lib/lexdrill/line_formatter.rb', line 29 def self.loop_info(total) counter = Lexdrill::Counter.new(Lexdrill::WordList::COUNTER_PATH) step_used = counter.value - 1 Lexdrill::Beat.loop_info(total, step_used) end |
.simple(word) ⇒ Object
18 19 20 21 |
# File 'lib/lexdrill/line_formatter.rb', line 18 def self.simple(word) count = Lexdrill::Stats.counts.fetch(word, 0) "#{Lexdrill::Colorizer.paint_blue(SEPARATOR)} #{Lexdrill::Colorizer.paint_by_count(word, count)}" end |