Class: IsoBibItem::CopyrightAssociation

Inherits:
Object
  • Object
show all
Defined in:
lib/iso_bib_item/bibliographic_item.rb

Overview

Copyright association.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner:, from:, to: nil) ⇒ CopyrightAssociation

Returns a new instance of CopyrightAssociation.

Parameters:

  • owner (Hash{name=>String, abbreviation=>String, url=>String})

    contributor

  • from (String)

    date

  • to (String) (defaults to: nil)

    date



61
62
63
64
65
66
67
# File 'lib/iso_bib_item/bibliographic_item.rb', line 61

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.parse(to) if to
end

Instance Attribute Details

#fromTime (readonly)

Returns:

  • (Time)


49
50
51
# File 'lib/iso_bib_item/bibliographic_item.rb', line 49

def from
  @from
end

#ownerIsobib::ContributionInfo (readonly)

Returns:

  • (Isobib::ContributionInfo)


55
56
57
# File 'lib/iso_bib_item/bibliographic_item.rb', line 55

def owner
  @owner
end

#toTime (readonly)

Returns:

  • (Time)


52
53
54
# File 'lib/iso_bib_item/bibliographic_item.rb', line 52

def to
  @to
end

Instance Method Details

#to_xml(builder) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/iso_bib_item/bibliographic_item.rb', line 69

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