class CFF::Identifier
An Identifier
represents an identifier in a CITATION.cff file.
Identifier
implements all of the fields listed in the [CFF standard](citation-file-format.github.io/). 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):
-
`description`
-
`type`
-
`value`
Constants
- IDENTIFIER_TYPES
The [defined set of identifier types](github.com/citation-file-format/citation-file-format/blob/main/README.md#identifier-type-strings).
Public Class Methods
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.
# File lib/cff/identifier.rb, line 46 def initialize(param = nil, *more) if param.is_a?(Hash) @fields = param @fields.default = '' else @fields = Hash.new('') unless param.nil? self.type = param @fields['value'] = more[0] unless @fields['type'].empty? end end yield self if block_given? end
Public Instance Methods
Sets the type of this Identifier
. The type is restricted to a [defined set of identifier types](github.com/citation-file-format/citation-file-format/blob/main/README.md#identifier-type-strings).
# File lib/cff/identifier.rb, line 67 def type=(type) type = type.downcase @fields['type'] = type if IDENTIFIER_TYPES.include?(type) end