class CFF::Identifier

An Identifier represents an identifier in a CITATION.cff file.

Identifier implements all of the fields listed in the CFF standard. All fields are simple strings and can be set as such. A field which has not been set will return the empty string. The simple fields are (with defaults in parentheses):

Constants

IDENTIFIER_TYPES

The defined set of identifier types.

Public Class Methods

new → Identifier click to toggle source
new { |id| block } → Identifier
new(type, value) → Identifier
new(type, value) { |id| block } → Identifier

Create a new Identifier with the optionally supplied type and value. If the supplied type is invalid, then neither the type or value are set.

Calls superclass method
# File lib/cff/identifier.rb, line 50
def initialize(param = nil, *more)
  super()

  if param.is_a?(Hash)
    @fields = param
  else
    @fields = {}

    unless param.nil?
      self.type = param
      @fields['value'] = more[0] unless @fields['type'].nil?
    end
  end

  yield self if block_given?
end

Public Instance Methods

type = type click to toggle source

Sets the type of this Identifier. The type is restricted to a defined set of identifier types.

# File lib/cff/identifier.rb, line 72
def type=(type)
  type = type.downcase
  @fields['type'] = type if IDENTIFIER_TYPES.include?(type)
end