Class: Prismic::Fragments::DocumentLink
- Includes:
- WithFragments
- Defined in:
- lib/prismic/fragments/link.rb
Instance Attribute Summary collapse
-
#broken ⇒ Object
(also: #broken?)
Returns the value of attribute broken.
-
#fragments ⇒ Object
Returns the value of attribute fragments.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
-
#uid ⇒ Object
Returns the value of attribute uid.
Instance Method Summary collapse
- #as_html(link_resolver = nil) ⇒ Object
- #end_html ⇒ Object
-
#initialize(id, uid, type, tags, slug, lang, fragments, broken, target = nil) ⇒ DocumentLink
constructor
A new instance of DocumentLink.
- #link_type ⇒ Object
- #start_html(link_resolver, target = nil) ⇒ Object
-
#url(link_resolver) ⇒ Object
Returns the URL of the link.
Methods included from WithFragments
#[], #as_text, #each, #first_title, #get_boolean_field, #get_color, #get_date, #get_embed, #get_geopoint, #get_group, #get_image, #get_link, #get_number, #get_slice_zone, #get_structured_text, #get_text, #get_timestamp, #length, #linked_documents
Methods inherited from Fragment
Constructor Details
#initialize(id, uid, type, tags, slug, lang, fragments, broken, target = nil) ⇒ DocumentLink
Returns a new instance of DocumentLink.
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/prismic/fragments/link.rb', line 112 def initialize(id, uid, type, , slug, lang, fragments, broken, target = nil) @id = id @uid = uid @type = type @tags = @slug = slug @lang = lang @fragments = fragments @broken = broken @target = target end |
Instance Attribute Details
#broken ⇒ Object Also known as: broken?
Returns the value of attribute broken.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def broken @broken end |
#fragments ⇒ Object
Returns the value of attribute fragments.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def fragments @fragments end |
#id ⇒ Object
Returns the value of attribute id.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def id @id end |
#lang ⇒ Object
Returns the value of attribute lang.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def lang @lang end |
#slug ⇒ Object
Returns the value of attribute slug.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def slug @slug end |
#tags ⇒ Object
Returns the value of attribute tags.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def @tags end |
#target ⇒ Object
Returns the value of attribute target.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def type @type end |
#uid ⇒ Object
Returns the value of attribute uid.
110 111 112 |
# File 'lib/prismic/fragments/link.rb', line 110 def uid @uid end |
Instance Method Details
#as_html(link_resolver = nil) ⇒ Object
132 133 134 |
# File 'lib/prismic/fragments/link.rb', line 132 def as_html(link_resolver=nil) %(#{start_html(link_resolver)}#{slug}#{end_html}) end |
#end_html ⇒ Object
128 129 130 |
# File 'lib/prismic/fragments/link.rb', line 128 def end_html broken? ? %(</span>) : super end |
#link_type ⇒ Object
136 137 138 139 |
# File 'lib/prismic/fragments/link.rb', line 136 def link_type warn('WARNING: DocumentLink.link_type is deprecated, use DocumentLink.type instead') self.type end |
#start_html(link_resolver, target = nil) ⇒ Object
124 125 126 |
# File 'lib/prismic/fragments/link.rb', line 124 def start_html(link_resolver, target = nil) broken? ? %(<span>) : super end |
#url(link_resolver) ⇒ Object
Returns the URL of the link
148 149 150 151 |
# File 'lib/prismic/fragments/link.rb', line 148 def url(link_resolver = nil) raise "A link_resolver method is needed to serialize document links into a correct URL on your website. If you're using a starter kit, a trivial one is provided out-of-the-box, that you can update later." if link_resolver == nil link_resolver.link_to(self) end |