Sha256: ecd0fde3bbb9c3548eeed988f3373c89191791b885d5f427e3c13eba9f33ffb0

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

module RelatonBib
  # Copyright association.
  class CopyrightAssociation
    # @return [Time]
    attr_reader :from

    # @return [Time]
    attr_reader :to

    # @return [RelatonBib::ContributionInfo]
    attr_reader :owner

    # @param owner [Hash, RelatonBib::ContributionInfo] contributor
    # @option owner [String] :name
    # @option owner [String] :abbreviation
    # @option owner [String] :url
    # @param from [String] date
    # @param to [String, NilClass] date
    def initialize(owner:, from:, to: nil)
      @owner = if owner.is_a?(Hash)
                 ContributionInfo.new entity: Organization.new(owner)
               else owner
               end

      @from  = Time.strptime(from, "%Y") unless from.empty?
      @to    = Time.strptime(to, "%Y") unless to.to_s.empty?
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.copyright do
        builder.from from.year
        builder.to to.year if to
        builder.owner { owner.to_xml builder }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
relaton-bib-0.3.3 lib/relaton_bib/copyright_association.rb
relaton-bib-0.3.2 lib/relaton_bib/copyright_association.rb
relaton-bib-0.3.1 lib/relaton_bib/copyright_association.rb
relaton-bib-0.3.0 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.5 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.4 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.3 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.2 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.1 lib/relaton_bib/copyright_association.rb
relaton-bib-0.2.0 lib/relaton_bib/copyright_association.rb
relaton-bib-0.1.6 lib/relaton_bib/copyright_association.rb
relaton-bib-0.1.5 lib/relaton_bib/copyright_association.rb
relaton-bib-0.1.3 lib/relaton_bib/copyright_association.rb