Module: IiifS3::BaseProperties

Includes:
Utilities::Helpers
Included in:
Collection, Manifest
Defined in:
lib/iiif_s3/base_properties.rb

Overview

TODO:

Add within, service, seeAlso, viewingHint fields

Module BaseProperties provides the set of properties that are shared across all IIIF types. It is not a comprehensive list (yet), but it does handle most of the shared types. It does not include any types that have class-based restrictions.

It also performs some basic sanity checking on (some of) the fields, and provides utility classes that are applicable across the fields.

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities::Helpers

#add_default_redirect, #add_file_to_s3, #generate_build_location, #generate_id, #generate_image_location, #get_data_path, #get_s3_key, #save_to_disk

Instance Attribute Details

#attributionString

Returns a human-readable label, typically used for attribution or credit.

Returns:

  • (String)

    a human-readable label, typically used for attribution or credit.



34
35
36
# File 'lib/iiif_s3/base_properties.rb', line 34

def attribution
  @attribution
end

#descriptionObject

@return [String] The long-form description of this record



# File 'lib/iiif_s3/base_properties.rb', line 26

#idObject

Returns the value of attribute id.



25
26
27
# File 'lib/iiif_s3/base_properties.rb', line 25

def id
  @id
end

#labelString

Returns The human-readable label for this record.

Returns:

  • (String)

    The human-readable label for this record



22
23
24
# File 'lib/iiif_s3/base_properties.rb', line 22

def label
  @label
end

#licenseString

Returns The URI to a resource that describes the license or rights statement associated.

Returns:

  • (String)

    The URI to a resource that describes the license or rights statement associated.



40
41
42
# File 'lib/iiif_s3/base_properties.rb', line 40

def license
  @license
end

#logoString

Returns The URI to an image for the logo of the institution associated with this record.

Returns:

  • (String)

    The URI to an image for the logo of the institution associated with this record.



37
38
39
# File 'lib/iiif_s3/base_properties.rb', line 37

def 
  @logo
end

#metadataHash

Returns A set of key/value pairs describing additional metadata for the object.

Returns:

  • (Hash)

    A set of key/value pairs describing additional metadata for the object.



31
32
33
# File 'lib/iiif_s3/base_properties.rb', line 31

def 
  @metadata
end

Returns The URI to related resources. Can be both a string or an array.

Returns:

  • (String, Array<String>)

    The URI to related resources. Can be both a string or an array



43
44
45
# File 'lib/iiif_s3/base_properties.rb', line 43

def related
  @related
end

Instance Method Details

#base_propertiesHash

Return the base data structure for this record as a Hash This will be in IIIF format, and should convert to JSON as JSON-LD nicely.

Returns:

  • (Hash)

    The base properties of this record



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/iiif_s3/base_properties.rb', line 65

def base_properties
  obj = { 
    "@context" => PRESENTATION_CONTEXT,
    "@id" => self.id,
    "@type" => self.type,
    "label" => self.label
  }
  obj["attribution"] = self.attribution if self.attribution
  obj["logo"] = self. if self.
  obj["description"] = self.description if self.description
  obj["attribution"] = self.attribution if self.attribution
  obj["license"] = self.license if self.license
  obj["related"] = self.related if self.related
  obj["metadata"] = self. if self.

  obj
end

#saveVoid

Save the JSON representation of this record to disk and to S3 (if enabled).

Returns:

  • (Void)


86
87
88
# File 'lib/iiif_s3/base_properties.rb', line 86

def save
  save_to_disk(JSON.parse(self.to_json))
end

#typeString

The type of resource provided by this record.

Returns:

  • (String)

    The type of record



48
49
50
# File 'lib/iiif_s3/base_properties.rb', line 48

def type
  self.class::TYPE
end