Class: PrawnHtml::Tags::Ol
- Inherits:
-
PrawnHtml::Tag
- Object
- PrawnHtml::Tag
- PrawnHtml::Tags::Ol
- Defined in:
- lib/prawn_html/tags/ol.rb
Constant Summary collapse
- ELEMENTS =
[:ol].freeze
- MARGIN_TOP =
15
- MARGIN_LEFT =
40
- MARGIN_BOTTOM =
15
Constants inherited from PrawnHtml::Tag
PrawnHtml::Tag::CALLBACKS, PrawnHtml::Tag::TAG_CLASSES
Instance Attribute Summary collapse
-
#counter ⇒ Object
Returns the value of attribute counter.
Attributes inherited from PrawnHtml::Tag
Instance Method Summary collapse
- #block? ⇒ Boolean
-
#initialize(tag, attributes: {}, options: {}) ⇒ Ol
constructor
A new instance of Ol.
- #on_context_add(context) ⇒ Object
- #tag_styles ⇒ Object
Methods inherited from PrawnHtml::Tag
#block_styles, class_for, #process_styles, #tag_close_styles, #tag_open_styles
Constructor Details
#initialize(tag, attributes: {}, options: {}) ⇒ Ol
Returns a new instance of Ol.
14 15 16 17 18 |
# File 'lib/prawn_html/tags/ol.rb', line 14 def initialize(tag, attributes: {}, options: {}) super @counter = 0 @first_level = false end |
Instance Attribute Details
#counter ⇒ Object
Returns the value of attribute counter.
12 13 14 |
# File 'lib/prawn_html/tags/ol.rb', line 12 def counter @counter end |
Instance Method Details
#block? ⇒ Boolean
20 21 22 |
# File 'lib/prawn_html/tags/ol.rb', line 20 def block? true end |
#on_context_add(context) ⇒ Object
24 25 26 27 28 |
# File 'lib/prawn_html/tags/ol.rb', line 24 def on_context_add(context) return if context.map(&:tag).count { |el| el == :ol } > 1 @first_level = true end |
#tag_styles ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/prawn_html/tags/ol.rb', line 30 def tag_styles if @first_level <<~STYLES margin-top: #{MARGIN_TOP}px; margin-left: #{MARGIN_LEFT}px; margin-bottom: #{MARGIN_BOTTOM}px; STYLES else "margin-left: #{MARGIN_LEFT}px" end end |