Sha256: 600b3c9585a93e2fd59d5e554b6e14d0981c2261da58d0dcaaccd4a559d94e54

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require 'wikibase_representable'

module DigitalScriptorium
  # Represents a Digital Scriptorium item
  class DsItem < WikibaseRepresentable::Model::Item
    def instance_of_claims
      claims_by_property_id PropertyId::INSTANCE_OF # P16
    end

    def ds_id
      claim_by_property_id(PropertyId::DS_ID)&.data_value # P1
    end

    def holding_id
      claim_by_property_id(PropertyId::MANUSCRIPT_HOLDING)&.entity_id_value # P2
    end

    def described_manuscript_id
      claim_by_property_id(PropertyId::DESCRIBED_MANUSCRIPT)&.entity_id_value # P3
    end

    def iiif_manifest
      claim_by_property_id(PropertyId::IIIF_MANIFEST)&.entity_id_value # P41
    end

    def core_model_item?
      instance_of_claims.any? { |claim| ItemId::CORE_MODEL_ITEMS.include? claim.entity_id_value }
    end

    def manuscript?
      instance_of_claims.any? { |claim| claim.entity_id_value == ItemId::MANUSCRIPT }
    end

    def holding?
      instance_of_claims.any? { |claim| claim.entity_id_value == ItemId::HOLDING }
    end

    def record?
      instance_of_claims.any? { |claim| claim.entity_id_value == ItemId::RECORD }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
digital_scriptorium-0.1.2 lib/digital_scriptorium/ds_item.rb
digital_scriptorium-0.1.1 lib/digital_scriptorium/ds_item.rb
digital_scriptorium-0.1.0 lib/digital_scriptorium/ds_item.rb