Class: Prismic::Document

Inherits:
Object
  • Object
show all
Includes:
WithFragments
Defined in:
lib/prismic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WithFragments

#[], #as_html, #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

Constructor Details

#initialize(id, uid, type, href, tags, slugs, first_publication_date, last_publication_date, fragments) ⇒ Document

Returns a new instance of Document



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/prismic.rb', line 460

def initialize(
  id,
  uid,
  type,
  href,
  tags,
  slugs,
  first_publication_date,
  last_publication_date,
  fragments
)
  @id = id
  @uid = uid
  @type = type
  @href = href
  @tags = tags
  @slugs = slugs
  @first_publication_date = first_publication_date
  @last_publication_date = last_publication_date
  @fragments = fragments
end

Instance Attribute Details

#first_publication_dateObject

Returns Time

Returns:

  • Time



454
455
456
# File 'lib/prismic.rb', line 454

def first_publication_date
  @first_publication_date
end

#fragmentsArray<Fragment>

Returns:

  • (Array<Fragment>)


458
459
460
# File 'lib/prismic.rb', line 458

def fragments
  @fragments
end

#hrefString

Returns:

  • (String)


448
449
450
# File 'lib/prismic.rb', line 448

def href
  @href
end

#idString

Returns:

  • (String)


442
443
444
# File 'lib/prismic.rb', line 442

def id
  @id
end

#last_publication_dateObject

Returns Time

Returns:

  • Time



456
457
458
# File 'lib/prismic.rb', line 456

def last_publication_date
  @last_publication_date
end

#slugsArray<String>

Returns:

  • (Array<String>)


452
453
454
# File 'lib/prismic.rb', line 452

def slugs
  @slugs
end

#tagsArray<String>

Returns:

  • (Array<String>)


450
451
452
# File 'lib/prismic.rb', line 450

def tags
  @tags
end

#typeString

Returns:

  • (String)


446
447
448
# File 'lib/prismic.rb', line 446

def type
  @type
end

#uidString

Returns:

  • (String)


444
445
446
# File 'lib/prismic.rb', line 444

def uid
  @uid
end

Instance Method Details

#slugString

Returns the document's slug

Returns:

  • (String)


485
486
487
# File 'lib/prismic.rb', line 485

def slug
  slugs.empty? ? '-' : slugs.first
end