Module: PrawnComponents::Components::Quote

Defined in:
lib/prawn_components/components/quote.rb

Instance Method Summary collapse

Instance Method Details

#quote(value, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/prawn_components/components/quote.rb', line 4

def quote(value, options = {})
  text_color = options.fetch(:text_color, '6A737D')
  border_color = options.fetch(:border_color, 'DFE2E5')

  callback = options.key?(:callback) ? options[:callback] : lambda { |x| x }
  parsed_value = if value.is_a?(Array)
    value.map { |e| [callback.call(e)] }
  else
    value.split("\n").map { |e| [callback.call(e)] }
  end

  quote_rows = parsed_value
  padding = [5, 0, 5, 15]
  border_width = 3

  table(quote_rows,
    cell_style: { 
      text_color: text_color, 
      borders: [:left], 
      border_color: border_color, 
      border_width: border_width, 
      padding: padding,
      inline_format: true
    }
  )
  move_down(20)
end