Class: Arrolio::Content::Document
- Inherits:
-
Object
- Object
- Arrolio::Content::Document
- Defined in:
- lib/arrolio/content/document.rb
Instance Attribute Summary collapse
-
#bibliography ⇒ Object
readonly
Returns the value of attribute bibliography.
-
#cover ⇒ Object
readonly
Returns the value of attribute cover.
-
#footnotes ⇒ Object
readonly
Returns the value of attribute footnotes.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#preface ⇒ Object
readonly
Returns the value of attribute preface.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
-
#style_id ⇒ Object
readonly
Returns the value of attribute style_id.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #docidentifier ⇒ Object
- #edition ⇒ Object
- #hash ⇒ Object
-
#initialize(metadata: {}, sections: [], preface: [], bibliography: [], cover: nil, style_id: :document, footnotes: []) ⇒ Document
constructor
A new instance of Document.
- #title ⇒ Object
Constructor Details
#initialize(metadata: {}, sections: [], preface: [], bibliography: [], cover: nil, style_id: :document, footnotes: []) ⇒ Document
Returns a new instance of Document.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/arrolio/content/document.rb', line 15 def initialize(metadata: {}, sections: [], preface: [], bibliography: [], cover: nil, style_id: :document, footnotes: []) @metadata = .to_h.freeze @sections = validate_sections(Array(sections), field: :sections).freeze @preface = validate_sections(Array(preface), field: :preface).freeze @bibliography = validate_sections(Array(bibliography), field: :bibliography).freeze @cover = cover @style_id = style_id.to_sym @footnotes = Array(footnotes).freeze freeze end |
Instance Attribute Details
#bibliography ⇒ Object (readonly)
Returns the value of attribute bibliography.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def bibliography @bibliography end |
#cover ⇒ Object (readonly)
Returns the value of attribute cover.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def cover @cover end |
#footnotes ⇒ Object (readonly)
Returns the value of attribute footnotes.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def footnotes @footnotes end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def @metadata end |
#preface ⇒ Object (readonly)
Returns the value of attribute preface.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def preface @preface end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def sections @sections end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
8 9 10 |
# File 'lib/arrolio/content/document.rb', line 8 def style_id @style_id end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
31 32 33 34 35 36 37 |
# File 'lib/arrolio/content/document.rb', line 31 def ==(other) other.is_a?(self.class) && == other. && sections == other.sections && preface == other.preface && bibliography == other.bibliography && cover == other.cover && style_id == other.style_id && footnotes == other.footnotes end |
#docidentifier ⇒ Object
28 |
# File 'lib/arrolio/content/document.rb', line 28 def docidentifier = @metadata[:docidentifier] || @metadata['docidentifier'] |
#edition ⇒ Object
29 |
# File 'lib/arrolio/content/document.rb', line 29 def edition = @metadata[:edition] || @metadata['edition'] |
#hash ⇒ Object
40 41 42 43 |
# File 'lib/arrolio/content/document.rb', line 40 def hash [self.class, , sections, preface, bibliography, cover, style_id, footnotes].hash end |
#title ⇒ Object
27 |
# File 'lib/arrolio/content/document.rb', line 27 def title = @metadata[:title] || @metadata['title'] |