Class: Tattoo::Gun

Inherits:
Object
  • Object
show all
Defined in:
lib/tattoo/gun.rb

Instance Method Summary collapse

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

#lookObject



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

#tattooObject



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