Class: Arclight::DigitalObject
- Inherits:
-
Object
- Object
- Arclight::DigitalObject
- Defined in:
- lib/arclight/digital_object.rb
Overview
Plain ruby class to model serializing/deserializing digital object data
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(label:, href:) ⇒ DigitalObject
constructor
A new instance of DigitalObject.
- #to_json ⇒ Object
Constructor Details
#initialize(label:, href:) ⇒ DigitalObject
Returns a new instance of DigitalObject.
9 10 11 12 |
# File 'lib/arclight/digital_object.rb', line 9 def initialize(label:, href:) @label = label.presence || href @href = href end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
7 8 9 |
# File 'lib/arclight/digital_object.rb', line 7 def href @href end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
7 8 9 |
# File 'lib/arclight/digital_object.rb', line 7 def label @label end |
Class Method Details
.from_json(json) ⇒ Object
18 19 20 21 |
# File 'lib/arclight/digital_object.rb', line 18 def self.from_json(json) object_data = JSON.parse(json) new(label: object_data['label'], href: object_data['href']) end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/arclight/digital_object.rb', line 23 def ==(other) href == other.href && label == other.label end |
#to_json ⇒ Object
14 15 16 |
# File 'lib/arclight/digital_object.rb', line 14 def to_json(*) { label: label, href: href }.to_json end |