Class: Mato::AnchorBuilder
- Inherits:
-
Object
- Object
- Mato::AnchorBuilder
- Defined in:
- lib/mato/anchor_builder.rb
Constant Summary collapse
- DEFAULT_ANCHOR_ICON_ELEMENT =
assumes use of font-awesome specify it as “<span aria-hidden="true" class="octicon octicon-link"></span>” if you use octicon
'<i class="fa fa-link"></i>'
- CSS_CLASS_NAME =
"anchor"
Instance Attribute Summary collapse
-
#anchor_icon_element ⇒ Object
readonly
Returns the value of attribute anchor_icon_element.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#initialize(anchor_icon_element = DEFAULT_ANCHOR_ICON_ELEMENT) ⇒ AnchorBuilder
constructor
A new instance of AnchorBuilder.
- #make_anchor_element(hx) ⇒ Object
- #make_anchor_id(hx) ⇒ Object
Constructor Details
#initialize(anchor_icon_element = DEFAULT_ANCHOR_ICON_ELEMENT) ⇒ AnchorBuilder
Returns a new instance of AnchorBuilder.
17 18 19 20 |
# File 'lib/mato/anchor_builder.rb', line 17 def initialize(anchor_icon_element = DEFAULT_ANCHOR_ICON_ELEMENT) @anchor_icon_element = anchor_icon_element @id_map = {} end |
Instance Attribute Details
#anchor_icon_element ⇒ Object (readonly)
Returns the value of attribute anchor_icon_element.
14 15 16 |
# File 'lib/mato/anchor_builder.rb', line 14 def anchor_icon_element @anchor_icon_element end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
15 16 17 |
# File 'lib/mato/anchor_builder.rb', line 15 def context @context end |
Instance Method Details
#make_anchor_element(hx) ⇒ Object
23 24 25 26 |
# File 'lib/mato/anchor_builder.rb', line 23 def make_anchor_element(hx) id = make_anchor_id(hx) %{<a id="#{id}" href="##{id}" aria-hidden="true" class="#{CSS_CLASS_NAME}">#{anchor_icon_element}</a>} end |
#make_anchor_id(hx) ⇒ Object
28 29 30 31 |
# File 'lib/mato/anchor_builder.rb', line 28 def make_anchor_id(hx) prefix = make_anchor_id_prefix(hx.inner_text) "#{prefix}#{make_anchor_id_suffix(prefix)}" end |