Class: OpenStax::Content::Book
- Inherits:
-
Object
- Object
- OpenStax::Content::Book
- Extended by:
- Forwardable
- Defined in:
- lib/openstax/content/book.rb
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #baked ⇒ Object
- #collated ⇒ Object
- #hash ⇒ Object
-
#initialize(archive:, uuid:, version:, url: nil, hash: nil, slug: nil, style: nil) ⇒ Book
constructor
A new instance of Book.
- #root_book_part ⇒ Object
- #short_id ⇒ Object
- #title ⇒ Object
- #tree ⇒ Object
- #url ⇒ Object
- #url_fragment ⇒ Object
Constructor Details
#initialize(archive:, uuid:, version:, url: nil, hash: nil, slug: nil, style: nil) ⇒ Book
Returns a new instance of Book.
8 9 10 11 12 13 14 15 16 |
# File 'lib/openstax/content/book.rb', line 8 def initialize(archive:, uuid:, version:, url: nil, hash: nil, slug: nil, style: nil) @archive = archive @uuid = uuid @version = version @url = url @hash = hash @slug = slug @style = style end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
6 7 8 |
# File 'lib/openstax/content/book.rb', line 6 def archive @archive end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
6 7 8 |
# File 'lib/openstax/content/book.rb', line 6 def slug @slug end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
6 7 8 |
# File 'lib/openstax/content/book.rb', line 6 def style @style end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
6 7 8 |
# File 'lib/openstax/content/book.rb', line 6 def uuid @uuid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/openstax/content/book.rb', line 6 def version @version end |
Instance Method Details
#baked ⇒ Object
30 31 32 |
# File 'lib/openstax/content/book.rb', line 30 def baked @baked ||= hash['baked'] end |
#collated ⇒ Object
34 35 36 |
# File 'lib/openstax/content/book.rb', line 34 def collated @collated ||= hash.fetch('collated', false) end |
#hash ⇒ Object
26 27 28 |
# File 'lib/openstax/content/book.rb', line 26 def hash @hash ||= archive.json url end |
#root_book_part ⇒ Object
50 51 52 |
# File 'lib/openstax/content/book.rb', line 50 def root_book_part @root_book_part ||= OpenStax::Content::BookPart.new(hash: tree, is_root: true, book: self) end |
#short_id ⇒ Object
38 39 40 |
# File 'lib/openstax/content/book.rb', line 38 def short_id @short_id ||= hash['shortId'] end |
#title ⇒ Object
42 43 44 |
# File 'lib/openstax/content/book.rb', line 42 def title @title ||= hash.fetch('title') end |
#tree ⇒ Object
46 47 48 |
# File 'lib/openstax/content/book.rb', line 46 def tree @tree ||= hash.fetch('tree') end |
#url ⇒ Object
18 19 20 |
# File 'lib/openstax/content/book.rb', line 18 def url @url ||= archive.url_for "#{uuid}@#{version}" end |
#url_fragment ⇒ Object
22 23 24 |
# File 'lib/openstax/content/book.rb', line 22 def url_fragment @url_fragment ||= url.chomp('.json') end |