Class: Prawn::Format::Effects::Underline

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

Instance Method Summary collapse

Constructor Details

#initialize(from, state) ⇒ Underline

Returns a new instance of Underline.



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

def initialize(from, state)
  @from = from
  @state = state
end

Instance Method Details

#finish(document, draw_state) ⇒ Object



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

def finish(document, draw_state)
  x1 = draw_state[:x] + @from
  x2 = draw_state[:x] + draw_state[:dx]
  y  = draw_state[:y] + draw_state[:dy] - 2

  document.stroke_color(@state.color)
  document.move_to(x1, y)
  document.line_to(x2, y)
  document.stroke
end

#wrap(document, draw_state) ⇒ Object



24
25
26
27
# File 'lib/prawn/format/effects/underline.rb', line 24

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