Sha256: 0154e446dce03342ff44dd0800f86cbb429426157924e227345b9ee58faa2616

Contents?: true

Size: 873 Bytes

Versions: 7

Compression:

Stored size: 873 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)
      i = super
      i.start_with?('#') ? i : "##{i}"
    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

7 entries across 7 versions & 1 rubygems

Version Path
ro-crate-0.4.15 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.14 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.13 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.12 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.11 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.10 lib/ro_crate/model/contextual_entity.rb
ro-crate-0.4.9 lib/ro_crate/model/contextual_entity.rb