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.
 - 
  
    
      #slug  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute slug.
 - 
  
    
      #tags  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute tags.
 - 
  
    
      #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, fragments, broken)  ⇒ DocumentLink 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of DocumentLink.
 - #link_type ⇒ Object
 - #start_html(link_resolver) ⇒ Object
 - 
  
    
      #url(link_resolver)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the URL of the link.
 
Methods included from WithFragments
#[], #as_text, #each, #first_title, #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, fragments, broken) ⇒ DocumentLink
Returns a new instance of DocumentLink
      101 102 103 104 105 106 107 108 109  | 
    
      # File 'lib/prismic/fragments/link.rb', line 101 def initialize(id, uid, type, , slug, fragments, broken) @id = id @uid = uid @type = type @tags = @slug = slug @fragments = fragments @broken = broken end  | 
  
Instance Attribute Details
#broken ⇒ Object Also known as: broken?
Returns the value of attribute broken
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def broken @broken end  | 
  
#fragments ⇒ Object
Returns the value of attribute fragments
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def fragments @fragments end  | 
  
#id ⇒ Object
Returns the value of attribute id
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def id @id end  | 
  
#slug ⇒ Object
Returns the value of attribute slug
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def slug @slug end  | 
  
#tags ⇒ Object
Returns the value of attribute tags
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def @tags end  | 
  
#type ⇒ Object
Returns the value of attribute type
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def type @type end  | 
  
#uid ⇒ Object
Returns the value of attribute uid
      99 100 101  | 
    
      # File 'lib/prismic/fragments/link.rb', line 99 def uid @uid end  | 
  
Instance Method Details
#as_html(link_resolver = nil) ⇒ Object
      119 120 121  | 
    
      # File 'lib/prismic/fragments/link.rb', line 119 def as_html(link_resolver=nil) %(#{start_html(link_resolver)}#{slug}#{end_html}) end  | 
  
#end_html ⇒ Object
      115 116 117  | 
    
      # File 'lib/prismic/fragments/link.rb', line 115 def end_html broken? ? %(</span>) : super end  | 
  
#link_type ⇒ Object
      123 124 125 126  | 
    
      # File 'lib/prismic/fragments/link.rb', line 123 def link_type warn('WARNING: DocumentLink.link_type is deprecated, use DocumentLink.type instead') self.type end  | 
  
#start_html(link_resolver) ⇒ Object
      111 112 113  | 
    
      # File 'lib/prismic/fragments/link.rb', line 111 def start_html(link_resolver) broken? ? %(<span>) : super end  | 
  
#url(link_resolver) ⇒ Object
Returns the URL of the link
      135 136 137 138  | 
    
      # File 'lib/prismic/fragments/link.rb', line 135 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  |