Class: Uniword::Builder::BibliographyBuilder
- Inherits:
-
Object
- Object
- Uniword::Builder::BibliographyBuilder
- Defined in:
- lib/uniword/builder/bibliography_builder.rb
Overview
Builds bibliography sources for a document.
Manages the Bibliography::Sources collection, providing factory methods for common source types (book, journal article, website, etc.).
Constant Summary collapse
- CHART_REL_TYPE =
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography"
Instance Attribute Summary collapse
-
#sources ⇒ Object
readonly
Returns the value of attribute sources.
Instance Method Summary collapse
-
#attach(document) ⇒ self
Attach the bibliography sources to a document.
-
#book(tag:, author:, title:, year:, publisher:, city: nil, edition: nil) ⇒ self
Create a book source.
-
#build ⇒ Bibliography::Sources
Build and return the Sources model.
-
#conference(tag:, author:, title:, year:, publisher:, city: nil) ⇒ self
Create a conference proceedings source.
-
#initialize(style: "APA") ⇒ BibliographyBuilder
constructor
A new instance of BibliographyBuilder.
-
#journal(tag:, author:, title:, year:, journal:, volume: nil, issue: nil, pages: nil) ⇒ self
Create a journal article source.
-
#source(tag:, source_type:, title:, author: nil, year: nil) ⇒ self
Create a generic/artistic source.
-
#style=(style) ⇒ self
Set the citation style.
-
#website(tag:, title:, url:, author: nil, year: nil) ⇒ self
Create a website source.
Constructor Details
#initialize(style: "APA") ⇒ BibliographyBuilder
Returns a new instance of BibliographyBuilder.
27 28 29 30 31 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 27 def initialize(style: "APA") @sources = Bibliography::Sources.new @sources.selected_style = style @ref_order_counter = 0 end |
Instance Attribute Details
#sources ⇒ Object (readonly)
Returns the value of attribute sources.
25 26 27 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 25 def sources @sources end |
Instance Method Details
#attach(document) ⇒ self
Attach the bibliography sources to a document
37 38 39 40 41 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 37 def attach(document) root = document.respond_to?(:model) ? document.model : document root.bibliography_sources = @sources self end |
#book(tag:, author:, title:, year:, publisher:, city: nil, edition: nil) ⇒ self
Create a book source
53 54 55 56 57 58 59 60 61 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 53 def book(tag:, author:, title:, year:, publisher:, city: nil, edition: nil) src = build_source("Book", tag: tag, author: , title: title, year: year, publisher: publisher, city: city, edition: edition) @sources.source << src self end |
#build ⇒ Bibliography::Sources
Build and return the Sources model
146 147 148 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 146 def build @sources end |
#conference(tag:, author:, title:, year:, publisher:, city: nil) ⇒ self
Create a conference proceedings source
108 109 110 111 112 113 114 115 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 108 def conference(tag:, author:, title:, year:, publisher:, city: nil) src = build_source("ConferenceProceedings", tag: tag, author: , title: title, year: year, publisher: publisher, city: city) @sources.source << src self end |
#journal(tag:, author:, title:, year:, journal:, volume: nil, issue: nil, pages: nil) ⇒ self
Create a journal article source
74 75 76 77 78 79 80 81 82 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 74 def journal(tag:, author:, title:, year:, journal:, volume: nil, issue: nil, pages: nil) src = build_source("JournalArticle", tag: tag, author: , title: title, year: year, publisher: journal, volume: volume, issue: issue, pages: pages) @sources.source << src self end |
#source(tag:, source_type:, title:, author: nil, year: nil) ⇒ self
Create a generic/artistic source
126 127 128 129 130 131 132 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 126 def source(tag:, source_type:, title:, author: nil, year: nil, **) src = build_source(source_type, tag: tag, author: , title: title, year: year, **) @sources.source << src self end |
#style=(style) ⇒ self
Set the citation style
138 139 140 141 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 138 def style=(style) @sources.selected_style = style self end |
#website(tag:, title:, url:, author: nil, year: nil) ⇒ self
Create a website source
92 93 94 95 96 97 |
# File 'lib/uniword/builder/bibliography_builder.rb', line 92 def website(tag:, title:, url:, author: nil, year: nil) src = build_source("InternetSite", tag: tag, author: , title: title, year: year, url: url) @sources.source << src self end |