class CFF::Entity

An Entity can represent different types of entities, e.g., a publishing company, or conference. Like a Person, an Entity might have a number of roles, such as author, contact, editor, etc.

Entity 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):

Public Class Methods

new(name) → Entity click to toggle source
new(name) { |entity| block } → Entity

Create a new Entity with the supplied name.

# File lib/cff/entity.rb, line 56
def initialize(param)
  if param.is_a?(Hash)
    @fields = param
    @fields.default = ''
  else
    @fields = Hash.new('')
    @fields['name'] = param
  end

  yield self if block_given?
end

Public Instance Methods

date_end = date click to toggle source

Set the `date-end` field. If a non-Date object is passed in it will be parsed into a Date.

# File lib/cff/entity.rb, line 73
def date_end=(date)
  date = Date.parse(date) unless date.is_a?(Date)

  @fields['date-end'] = date
end
date_start = date click to toggle source

Set the `date-start` field. If a non-Date object is passed in it will be parsed into a Date.

# File lib/cff/entity.rb, line 84
def date_start=(date)
  date = Date.parse(date) unless date.is_a?(Date)

  @fields['date-start'] = date
end