Sha256: 282882e2a68cb481eab72caef105ed9bd278ed5ae1a7026a51e4d192a927c8da

Contents?: true

Size: 578 Bytes

Versions: 14

Compression:

Stored size: 578 Bytes

Contents

# frozen_string_literal: true

module Arclight
  ##
  # Plain ruby class to model serializing/deserializing digital object data
  class DigitalObject
    attr_reader :label, :href

    def initialize(label:, href:)
      @label = label.presence || href
      @href = href
    end

    def to_json(*)
      { label: label, href: href }.to_json
    end

    def self.from_json(json)
      object_data = JSON.parse(json)
      new(label: object_data['label'], href: object_data['href'])
    end

    def ==(other)
      href == other.href && label == other.label
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
arclight-1.4.0 lib/arclight/digital_object.rb
arclight-1.3.0 lib/arclight/digital_object.rb
arclight-1.2.0 lib/arclight/digital_object.rb
arclight-1.1.3 lib/arclight/digital_object.rb
arclight-1.1.2 lib/arclight/digital_object.rb
arclight-1.1.1 lib/arclight/digital_object.rb
arclight-1.1.0 lib/arclight/digital_object.rb
arclight-1.0.1 lib/arclight/digital_object.rb
arclight-1.0.0 lib/arclight/digital_object.rb
arclight-1.0.0.beta6 lib/arclight/digital_object.rb
arclight-1.0.0.beta4 lib/arclight/digital_object.rb
arclight-1.0.0.beta3 lib/arclight/digital_object.rb
arclight-1.0.0.beta2 lib/arclight/digital_object.rb
arclight-1.0.0.beta1 lib/arclight/digital_object.rb