Class: PrawnHtml::Tags::Hr

Inherits:
PrawnHtml::Tag show all
Defined in:
lib/prawn_html/tags/hr.rb

Constant Summary collapse

ELEMENTS =
[:hr].freeze
MARGIN_BOTTOM =
12
MARGIN_TOP =
6

Constants inherited from PrawnHtml::Tag

PrawnHtml::Tag::CALLBACKS, PrawnHtml::Tag::TAG_CLASSES

Instance Attribute Summary

Attributes inherited from PrawnHtml::Tag

#attrs, #parent, #tag

Instance Method Summary collapse

Methods inherited from PrawnHtml::Tag

#block_styles, class_for, #initialize, #process_styles, #tag_close_styles, #tag_open_styles

Constructor Details

This class inherits a constructor from PrawnHtml::Tag

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/prawn_html/tags/hr.rb', line 11

def block?
  true
end

#custom_render(pdf, _context) ⇒ Object



15
16
17
18
# File 'lib/prawn_html/tags/hr.rb', line 15

def custom_render(pdf, _context)
  dash = attrs.data.include?('dash') ? parse_dash_value(attrs.data['dash']) : nil
  pdf.horizontal_rule(color: attrs.styles[:color], dash: dash)
end

#tag_stylesObject



20
21
22
23
24
25
# File 'lib/prawn_html/tags/hr.rb', line 20

def tag_styles
  <<~STYLES
    margin-bottom: #{MARGIN_BOTTOM}px;
    margin-top: #{MARGIN_TOP}px;
  STYLES
end