Sha256: 3e6f63fa7b831a5ee66a807e19afd7ab1d4ceaa8397ccadafc789489461b2282

Contents?: true

Size: 867 Bytes

Versions: 5

Compression:

Stored size: 867 Bytes

Contents

module ROCrate
  ##
  # A class to represent a "Contextual Entity" within an RO-Crate.
  # Contextual Entities are used to describe and provide context to the Data Entities within the crate.
  class ContextualEntity < Entity
    def self.format_local_id(id)
      super(id.start_with?('#') ? id : "##{id}")
    end

    ##
    # Return an appropriate specialization of ContextualEntity for the given properties.
    # @param props [Hash] Set of properties to try and infer the type from.
    # @return [Class]
    def self.specialize(props)
      type = props['@type']
      type = [type] unless type.is_a?(Array)
      if type.include?('Person')
        ROCrate::Person
      elsif type.include?('Organization')
        ROCrate::Organization
      elsif type.include?('ContactPoint')
        ROCrate::ContactPoint
      else
        self
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ro-crate-0.5.2 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.5.1 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.5.0 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.17 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.16 lib/ro_crate/model/contextual_entity.rb