Class: IIIFManifest::ManifestBuilder::CanvasBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/iiif_manifest/manifest_builder/canvas_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, parent, iiif_canvas_factory:, image_builder:) ⇒ CanvasBuilder

Returns a new instance of CanvasBuilder.



6
7
8
9
10
11
12
13
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 6

def initialize(record, parent, iiif_canvas_factory:, image_builder:)
  @record = record
  @parent = parent
  @iiif_canvas_factory = iiif_canvas_factory
  @image_builder = image_builder
  apply_record_properties
  attach_image if display_image
end

Instance Attribute Details

#iiif_canvas_factoryObject (readonly)

Returns the value of attribute iiif_canvas_factory.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 4

def iiif_canvas_factory
  @iiif_canvas_factory
end

#image_builderObject (readonly)

Returns the value of attribute image_builder.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 4

def image_builder
  @image_builder
end

#parentObject (readonly)

Returns the value of attribute parent.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 4

def parent
  @parent
end

#recordObject (readonly)

Returns the value of attribute record.



4
5
6
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 4

def record
  @record
end

Instance Method Details

#apply(sequence) ⇒ Object



23
24
25
26
27
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 23

def apply(sequence)
  return sequence if canvas.images.blank?
  sequence.canvases += [canvas]
  sequence
end

#canvasObject



15
16
17
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 15

def canvas
  @canvas ||= iiif_canvas_factory.new
end

#pathObject



19
20
21
# File 'lib/iiif_manifest/manifest_builder/canvas_builder.rb', line 19

def path
  "#{parent.manifest_url}/canvas/#{record.id}"
end