Class: Metanorma::Release::AggregatedDocument
- Inherits:
-
Object
- Object
- Metanorma::Release::AggregatedDocument
- Defined in:
- lib/metanorma/release/document_index.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#content_hash ⇒ Object
readonly
Returns the value of attribute content_hash.
-
#doctype ⇒ Object
readonly
Returns the value of attribute doctype.
-
#edition ⇒ Object
readonly
Returns the value of attribute edition.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, title:, edition:, stage:, doctype:, channels:, formats:, flavor:, content_hash:, source:, files:) ⇒ AggregatedDocument
constructor
A new instance of AggregatedDocument.
- #to_h ⇒ Object
Constructor Details
#initialize(id:, title:, edition:, stage:, doctype:, channels:, formats:, flavor:, content_hash:, source:, files:) ⇒ AggregatedDocument
Returns a new instance of AggregatedDocument.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/metanorma/release/document_index.rb', line 55 def initialize(id:, title:, edition:, stage:, doctype:, channels:, formats:, flavor:, content_hash:, source:, files:) @id = id @title = title @edition = edition @stage = stage @doctype = doctype @channels = channels.freeze @formats = formats.freeze @flavor = flavor @content_hash = content_hash @source = source @files = files.freeze freeze end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def channels @channels end |
#content_hash ⇒ Object (readonly)
Returns the value of attribute content_hash.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def content_hash @content_hash end |
#doctype ⇒ Object (readonly)
Returns the value of attribute doctype.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def doctype @doctype end |
#edition ⇒ Object (readonly)
Returns the value of attribute edition.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def edition @edition end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def files @files end |
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def flavor @flavor end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def formats @formats end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def id @id end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def source @source end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def stage @stage end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
52 53 54 |
# File 'lib/metanorma/release/document_index.rb', line 52 def title @title end |
Class Method Details
.from_h(hash) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/metanorma/release/document_index.rb', line 33 def self.from_h(hash) files = (hash['files'] || []).map do |f| DocumentFile.new(name: f['name'], path: f['path']) end source_data = hash['source'] || {} source = DocumentSource.new( owner: source_data['owner'], repo: source_data['repo'], tag: source_data['tag'], release_url: source_data['releaseUrl'], release_date: source_data['releaseDate'] ) new( id: hash['id'], title: hash['title'], edition: hash['edition'], stage: hash['stage'], doctype: hash.fetch('doctype', ''), channels: hash['channels'] || [], formats: hash['formats'] || [], flavor: hash['flavor'], content_hash: hash['contentHash'], source: source, files: files ) end |
Instance Method Details
#to_h ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/metanorma/release/document_index.rb', line 71 def to_h { 'id' => id, 'title' => title, 'edition' => edition, 'stage' => stage, 'doctype' => doctype, 'channels' => channels, 'formats' => formats, 'flavor' => flavor, 'contentHash' => content_hash, 'source' => { 'owner' => source.owner, 'repo' => source.repo, 'tag' => source.tag, 'releaseUrl' => source.release_url, 'releaseDate' => source.release_date }, 'files' => files.map { |f| { 'name' => f.name, 'path' => f.path } } } end |