Class: Nineteen::Eighty::Two::Formats::Text

Inherits:
Object
  • Object
show all
Defined in:
lib/nineteen/eighty/two/formatters/text_formatter.rb

Class Method Summary collapse

Class Method Details

.format(text, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/nineteen/eighty/two/formatters/text_formatter.rb', line 6

def self.format text, options = {}
  on = options.fetch(:on, '1')
  off = options.fetch(:off, '0')

  Spectrum[*text].map do |t|
    t.join
  end.join("\n").
      gsub('0', off).
      gsub('1', on)
end