Class: RelatonBib::DocRelationCollection
- Extended by:
- Forwardable
- Defined in:
- lib/relaton_bib/document_relation_collection.rb
Overview
Document relation collection
Instance Method Summary collapse
-
#initialize(relation) ⇒ DocRelationCollection
constructor
A new instance of DocRelationCollection.
- #replaces ⇒ RelatonBib::DocRelationCollection
- #to_asciibib(prefix = "") ⇒ String
Constructor Details
#initialize(relation) ⇒ DocRelationCollection
Returns a new instance of DocRelationCollection.
20 21 22 |
# File 'lib/relaton_bib/document_relation_collection.rb', line 20 def initialize(relation) @array = relation.map { |r| r.is_a?(Hash) ? DocumentRelation.new(**r) : r } end |
Instance Method Details
#replaces ⇒ RelatonBib::DocRelationCollection
TODO:
We don’t have replace type anymore. Suppose we should update this method or delete it.
28 29 30 |
# File 'lib/relaton_bib/document_relation_collection.rb', line 28 def replaces DocRelationCollection.new(@array.select { |r| r.type == "replace" }) end |
#to_asciibib(prefix = "") ⇒ String
34 35 36 37 38 39 40 41 42 |
# File 'lib/relaton_bib/document_relation_collection.rb', line 34 def to_asciibib(prefix = "") pref = prefix.empty? ? "relation" : prefix + ".relation" out = "" @array.each do |r| out += size > 1 ? "#{pref}::\n" : "" out += r.to_asciibib pref end out end |