class ROCrate::DataEntity

A class to represent a “Data Entity” within an RO-Crate. Data Entities are the actual physical files and directories within the Crate.

Public Class Methods

format_local_id(id) click to toggle source
Calls superclass method
# File lib/ro_crate/model/data_entity.rb, line 8
def self.format_local_id(id)
  super.chomp('/')
end
specialize(props) click to toggle source

Return an appropriate specialization of DataEntity for the given properties. @param props [Hash] Set of properties to try and infer the type from. @return [Class]

# File lib/ro_crate/model/data_entity.rb, line 16
def self.specialize(props)
  type = props['@type']
  type = [type] unless type.is_a?(Array)
  if type.include?('Dataset')
    ROCrate::Directory
  else
    ROCrate::File
  end
end

Public Instance Methods

entries() click to toggle source

A map of all the files/directories associated with this DataEntity.

@return [Hash{String => Entry}>] The key is the location within the crate, and the value is an Entry.

# File lib/ro_crate/model/data_entity.rb, line 30
def entries
  {}
end
filepath() click to toggle source

A disk-safe filepath based on the ID of this DataEntity.

@return [String] The relative file path of this DataEntity within the Crate.

# File lib/ro_crate/model/data_entity.rb, line 38
def filepath
  Addressable::URI.unescape(id.sub(/\A\//, '')).to_s # Remove initial / and decode %20 etc.
end