Module: Fourmi::Prawn::Utils::Extensions::Box
- Defined in:
- lib/fourmi/prawn/utils/extensions/box.rb
Instance Method Summary collapse
- #filled_box(color, x: 0, y: cursor, width: bounds.width, height: 150, &block) ⇒ Object
- #list(text, options = {}) ⇒ Object
- #padded_box(position, padding, **options, &block) ⇒ Object
- #textbox(content = nil, height = 40) ⇒ Object
Instance Method Details
#filled_box(color, x: 0, y: cursor, width: bounds.width, height: 150, &block) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/fourmi/prawn/utils/extensions/box.rb', line 35 def filled_box(color, x: 0, y: cursor, width: bounds.width, height: 150, &block) fill_color(color) do fill_rectangle [x, y], width, height end bounding_box([x, y], width: width, height: height, &block) end |
#list(text, options = {}) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/fourmi/prawn/utils/extensions/box.rb', line 42 def list(text, = {}) float { indent(5) { text '- ' } } indent 15 do textj text, end end |
#padded_box(position, padding, **options, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fourmi/prawn/utils/extensions/box.rb', line 18 def padded_box(position, padding, **, &block) rounded = .delete(:rounded) rounded = true if rounded.nil? bounding_box position, do bounding_box [padding, bounds.top - padding], width: bounds.width - 2 * padding, height: bounds.height > 2 * padding ? bounds.height - 2 * padding : nil do yield block move_down padding end if rounded stroke_rounded_bounds else stroke_bounds end end end |
#textbox(content = nil, height = 40) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fourmi/prawn/utils/extensions/box.rb', line 6 def textbox(content = nil, height = 40) bounding_box([0, cursor], height: content.blank? && !block_given? ? height : nil, width: bounds.width) do pad(5) do indent(5) do text content unless content.blank? yield if block_given? end end stroke_bounds end end |