Sha256: 8ba8fb8ad577ce4cb61a92325068e1539f97e47510d02b65ece6de34e9cc7998
Contents?: true
Size: 1.85 KB
Versions: 3
Compression:
Stored size: 1.85 KB
Contents
require 'securerandom' require 'epubber/models/concerns/has_chapters' require 'epubber/models/concerns/has_introduction' require 'epubber/models/concerns/has_endnotes' # Represents a book with it's chapters. module Epubber::Models class Book # Related models and their DSL goodies include Epubber::Models::Concerns::HasChapters include Epubber::Models::Concerns::HasIntroduction include Epubber::Models::Concerns::HasEndnotes def initialize @title = not_specified @author = not_specified @publisher = not_specified @language = 'en' @url = not_specified # LIST / OF / SUBJECTS => https://www.bisg.org/complete-bisac-subject-headings-2014-edition @subjects = 'NON000000 NON-CLASSIFIABLE' @isbn = nil end def title(text = nil) return @title if text.nil? @title = text end def author(text) @author = text end def publisher(text) @publisher = text end def language(lang) @language = lang end def url(url) @url = url end def subjects(subjects) @subjects = subjects end def isbn(isbn) @isbn = isbn end # Return a hash which can be used as a template's context def contextify context = { # Attributes "title" => @title, "author" => @author, "publisher" => @publisher, "language" => @language, "url" => @url, "subjects" => @subjects, "uuid" => ::SecureRandom.uuid, "isbn" => @isbn } # Related models context["chapters"] = contextified_chapters context["introduction"] = contextified_introduction context["endnotes"] = contextified_endnotes return context end protected def not_specified 'Not specified' end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
epubber-0.1.3 | lib/epubber/models/book.rb |
epubber-0.1.2 | lib/epubber/models/book.rb |
epubber-0.1.1 | lib/epubber/models/book.rb |