Class: Tart::Builder
- Inherits:
-
Object
- Object
- Tart::Builder
- Defined in:
- lib/tart/builder.rb
Constant Summary collapse
- PIXEL =
"██"
- SPACE =
" "
Instance Method Summary collapse
- #draw(char) ⇒ Object
-
#initialize(filename, options = {}) ⇒ Builder
constructor
A new instance of Builder.
- #pixel(color) ⇒ Object
- #process ⇒ Object
- #space ⇒ Object
Constructor Details
Instance Method Details
#draw(char) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/tart/builder.rb', line 27 def draw(char) case char when "." then space when "K" then pixel :black when "R" then pixel :red when "G" then pixel :green when "Y" then pixel :yellow when "B" then pixel :blue when "M" then pixel :magenta when "C" then pixel :cyan when "W" then pixel :white when "k" then pixel :light_black when "r" then pixel :light_red when "g" then pixel :light_green when "y" then pixel :light_yellow when "b" then pixel :light_blue when "m" then pixel :light_magenta when "c" then pixel :light_cyan when "w" then pixel :light_white when "X","x" then pixel :default end end |
#pixel(color) ⇒ Object
53 54 55 |
# File 'lib/tart/builder.rb', line 53 def pixel(color) @pixel.colorize(color) end |
#process ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tart/builder.rb', line 15 def process output_str = "" IO.foreach(@filename) do |l| l.split('').each do |char| output_str << draw(char).to_s end output_str << "\n" end output_str end |
#space ⇒ Object
57 58 59 |
# File 'lib/tart/builder.rb', line 57 def space @space end |