Class: CFF::Entity
Overview
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.
Constant Summary collapse
- ALLOWED_FIELDS =
[ 'address', 'city', 'country', 'email', 'date-end', 'date-start', 'fax', 'location', 'name', 'orcid', 'post-code', 'region', 'tel', 'website' ].freeze
Instance Attribute Summary
Attributes inherited from ModelPart
Instance Method Summary collapse
-
#date_end=(date) ⇒ Object
:call-seq: date_end = date.
-
#date_start=(date) ⇒ Object
:call-seq: date_start = date.
-
#initialize(param) ⇒ Entity
constructor
:call-seq: new(name) -> Entity.
Methods inherited from ModelPart
#method_missing, #respond_to_missing?
Methods included from Util
#build_actor_collection!, #fields_to_hash, #method_to_field, #normalize_modelpart_array!
Constructor Details
#initialize(param) ⇒ Entity
:call-seq:
new(name) -> Entity
Create a new Entity with the supplied name.
32 33 34 35 36 37 38 39 |
# File 'lib/cff/entity.rb', line 32 def initialize(param) if param.is_a?(Hash) @fields = param else @fields = Hash.new('') @fields['name'] = param end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CFF::ModelPart
Instance Method Details
#date_end=(date) ⇒ Object
:call-seq:
date_end = date
Set the ‘date-end` field. If a non-Date object is passed in it will be parsed into a Date.
46 47 48 49 50 |
# File 'lib/cff/entity.rb', line 46 def date_end=(date) date = Date.parse(date) unless date.is_a?(Date) @fields['date-end'] = date end |
#date_start=(date) ⇒ Object
:call-seq:
date_start = date
Set the ‘date-start` field. If a non-Date object is passed in it will be parsed into a Date.
57 58 59 60 61 |
# File 'lib/cff/entity.rb', line 57 def date_start=(date) date = Date.parse(date) unless date.is_a?(Date) @fields['date-start'] = date end |