Class: Prismic::Fragments::StructuredText::Span::Hyperlink
- Inherits:
-
Prismic::Fragments::StructuredText::Span
- Object
- Prismic::Fragments::StructuredText::Span
- Prismic::Fragments::StructuredText::Span::Hyperlink
- Defined in:
- lib/prismic/fragments/structured_text.rb
Instance Attribute Summary collapse
-
#link ⇒ Object
Returns the value of attribute link.
Attributes inherited from Prismic::Fragments::StructuredText::Span
Instance Method Summary collapse
-
#initialize(start, finish, link) ⇒ Hyperlink
constructor
A new instance of Hyperlink.
- #serialize(text, link_resolver = nil) ⇒ Object
Constructor Details
#initialize(start, finish, link) ⇒ Hyperlink
Returns a new instance of Hyperlink
134 135 136 137 |
# File 'lib/prismic/fragments/structured_text.rb', line 134 def initialize(start, finish, link) super(start, finish) @link = link end |
Instance Attribute Details
#link ⇒ Object
Returns the value of attribute link
133 134 135 |
# File 'lib/prismic/fragments/structured_text.rb', line 133 def link @link end |
Instance Method Details
#serialize(text, link_resolver = nil) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/prismic/fragments/structured_text.rb', line 138 def serialize(text, link_resolver = nil) if link.is_a? Prismic::Fragments::DocumentLink and link.broken "<span>#{text}</span>" else %(<a href="#{link.url(link_resolver)}">#{text}</a>) end end |