Class: ColoringBackend
- Defined in:
- lib/backends/coloring_backend.rb
Overview
This backend is just a dummy that isn’t actually useful for anything other than testing purposes.
Constant Summary collapse
- COLORS =
['white', 'red', 'green', 'blue', 'black']
Class Attribute Summary collapse
-
.layers ⇒ Object
readonly
Returns the value of attribute layers.
Class Method Summary collapse
Methods inherited from Backend
Class Attribute Details
.layers ⇒ Object (readonly)
Returns the value of attribute layers.
9 10 11 |
# File 'lib/backends/coloring_backend.rb', line 9 def layers @layers end |
Class Method Details
.run(file) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/backends/coloring_backend.rb', line 11 def run(file) @layers = {} text = File.read(file) COLORS.each do |color| offset = 0 while occurance = text.index(color, offset) do (@layers[file] ||= []) << Layer.new((occurance ... occurance + color.length), color, "Found a #{color}", self) offset += (occurance + 1) end end write_layers end |