class CSL::Info

{Info} nodes contain a {Style} (or {Locale}) metadata. Their XML structure is based on the Atom Syndication Format. For independent styles an {Info} node typically has the following child elements:

In dependent styles, the {Info} node must contain a {Link} with rel set to “independent-parent”, with the URI of the independent parent style set on href. This link is also accessible as a string using the {#independent_parent} accessors. In addition, dependent styles should not contain template links.

In a {Locale} node the {Info} node typically carries only {Translator}, {Rights} and {Updated} nodes.

Public Class Methods

new(attributes = {}) { |self| ... } click to toggle source
Calls superclass method
# File lib/csl/info.rb, line 48
def initialize(attributes = {})
  super(attributes, &nil)
  children[:link], children[:category] = [], []

  yield self if block_given?
end

Public Instance Methods

citation_format() click to toggle source

@return [Symbol] the parent style's citation format

# File lib/csl/info.rb, line 175
def citation_format
  return unless has_categories?

  cat = categories.detect { |c| c.attribute? :'citation-format' }
  return if cat.nil?

  cat[:'citation-format'].to_sym
end
citation_format=(new_format) click to toggle source
# File lib/csl/info.rb, line 184
def citation_format=(new_format)
  cat = categories.detect { |c| c.attribute? :'citation-format' }
  cat = add_child Info::Category.new if cat.nil?

  cat[:'citation-format'] = new_format.to_s
end
default_license!() click to toggle source
# File lib/csl/info.rb, line 163
def default_license!
  if has_rights?
    rights[:license] = Schema.default_license
    rights.text = Schema.default_rights_string
  else
    add_child Rights.new(:license => Schema.default_license) { |r|
      r.text = Schema.default_rights_string
    }
  end
end
default_license?() click to toggle source
# File lib/csl/info.rb, line 158
def default_license?
  has_rights? && rights[:license] == Schema.default_license &&
    rights.text == Schema.default_rights_string
end
id() click to toggle source

@return [Id] the id text node

# File lib/csl/info.rb, line 94
def id
  children[:id]
end
license() click to toggle source
# File lib/csl/info.rb, line 145
def license
  return unless has_rights?
  rights[:license] || rights.to_s
end
license=(license) click to toggle source
# File lib/csl/info.rb, line 150
def license=(license)
  if has_rights?
    rights[:license] = license
  else
    add_child Rights.new(:license => license)
  end
end
publish!(timestamp = Time.now) click to toggle source

Sets the updated_at timestamp. @return [self]

# File lib/csl/info.rb, line 133
def publish!(timestamp = Time.now)
  ts = timestamp.respond_to?(:xmlschema) ? timestamp.xmlschema : timestamp.to_s

  if has_published?
    published.text = ts
  else
    add_child Published.new { |u| u.text = ts }
  end

  self
end
published_at() click to toggle source

@return [Time,nil] when the info node's parent was published

# File lib/csl/info.rb, line 126
def published_at
  return unless has_published?
  published.to_time
end
update!(timestamp = Time.now) click to toggle source

Sets the updated_at timestamp. @return [self]

# File lib/csl/info.rb, line 113
def update!(timestamp = Time.now)
  ts = timestamp.respond_to?(:xmlschema) ? timestamp.xmlschema : timestamp.to_s

  if has_updated?
    updated.text = ts
  else
    add_child Updated.new { |u| u.text = ts }
  end

  self
end
updated_at() click to toggle source

@return [Time,nil] when the info node's parent was last updated

# File lib/csl/info.rb, line 106
def updated_at
  return unless has_updated?
  updated.to_time
end