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.
-
#title_block ⇒ Object
readonly
Returns the value of attribute title_block.
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: [], title_block: nil) ⇒ Document
constructor
A new instance of Document.
- #title ⇒ Object
Constructor Details
#initialize(metadata: {}, sections: [], preface: [], bibliography: [], cover: nil, style_id: :document, footnotes: [], title_block: nil) ⇒ Document
Returns a new instance of Document.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/arrolio/content/document.rb', line 14 def initialize(metadata: {}, sections: [], preface: [], bibliography: [], cover: nil, style_id: :document, footnotes: [], title_block: nil) @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 @title_block = title_block freeze end |
Instance Attribute Details
#bibliography ⇒ Object (readonly)
Returns the value of attribute bibliography.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def bibliography @bibliography end |
#cover ⇒ Object (readonly)
Returns the value of attribute cover.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def cover @cover end |
#footnotes ⇒ Object (readonly)
Returns the value of attribute footnotes.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def footnotes @footnotes end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def @metadata end |
#preface ⇒ Object (readonly)
Returns the value of attribute preface.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def preface @preface end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def sections @sections end |
#style_id ⇒ Object (readonly)
Returns the value of attribute style_id.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def style_id @style_id end |
#title_block ⇒ Object (readonly)
Returns the value of attribute title_block.
7 8 9 |
# File 'lib/arrolio/content/document.rb', line 7 def title_block @title_block end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
32 33 34 35 36 37 38 |
# File 'lib/arrolio/content/document.rb', line 32 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
29 |
# File 'lib/arrolio/content/document.rb', line 29 def docidentifier = @metadata[:docidentifier] || @metadata['docidentifier'] |
#edition ⇒ Object
30 |
# File 'lib/arrolio/content/document.rb', line 30 def edition = @metadata[:edition] || @metadata['edition'] |
#hash ⇒ Object
41 42 43 44 |
# File 'lib/arrolio/content/document.rb', line 41 def hash [self.class, , sections, preface, bibliography, cover, style_id, footnotes].hash end |
#title ⇒ Object
28 |
# File 'lib/arrolio/content/document.rb', line 28 def title = @metadata[:title] || @metadata['title'] |