Class: Tattoo::Gun
- Inherits:
-
Object
- Object
- Tattoo::Gun
- Defined in:
- lib/tattoo/gun.rb
Instance Method Summary collapse
-
#initialize(text, ink = []) ⇒ Gun
constructor
A new instance of Gun.
- #look ⇒ Object
- #tattoo ⇒ Object
Constructor Details
#initialize(text, ink = []) ⇒ Gun
Returns a new instance of Gun.
3 4 5 6 |
# File 'lib/tattoo/gun.rb', line 3 def initialize(text, ink=[]) @text = text @ink = ink.inject({}) {|coll, i| coll[i.name] = i; coll} end |
Instance Method Details
#look ⇒ Object
8 9 10 11 12 13 |
# File 'lib/tattoo/gun.rb', line 8 def look @ink.values.inject({}) do |markings, ink| markings[ink.name] = ink.find_markings(@text) markings end end |
#tattoo ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/tattoo/gun.rb', line 15 def tattoo text = @text.dup look.each do |name, markings| markings.each do |marking| text = @ink[name].mark(marking, text) end end text end |