Class: Prawn::Format::Effects::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/format/effects/link.rb

Instance Method Summary collapse

Constructor Details

#initialize(target, x) ⇒ Link

Returns a new instance of Link.



8
9
10
11
# File 'lib/prawn/format/effects/link.rb', line 8

def initialize(target, x)
  @target = target.sub(/^#/, "")
  @x = x
end

Instance Method Details

#finish(document, draw_state) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/prawn/format/effects/link.rb', line 13

def finish(document, draw_state)
  x1 = draw_state[:real_x] + @x
  x2 = draw_state[:real_x] + draw_state[:dx]
  y  = draw_state[:real_y] + draw_state[:dy]

  rect = [x1, y + draw_state[:line].descent, x2, y + draw_state[:line].ascent]
  document.link_annotation(rect, :Dest => @target, :Border => [0,0,0])
end

#wrap(document, draw_state) ⇒ Object



22
23
24
25
# File 'lib/prawn/format/effects/link.rb', line 22

def wrap(document, draw_state)
  finish(document, draw_state)
  @x = 0
end