Class: Hydra::Works::CharacterizationService

Inherits:
Object
  • Object
show all
Defined in:
lib/hydra/works/services/characterization_service.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, source, options) ⇒ CharacterizationService

Returns a new instance of CharacterizationService.



15
16
17
18
19
20
21
# File 'lib/hydra/works/services/characterization_service.rb', line 15

def initialize(object, source, options)
  @object       = object
  @source       = source
  @mapping      = options.fetch(:parser_mapping, Hydra::Works::Characterization.mapper)
  @parser_class = options.fetch(:parser_class, Hydra::Works::Characterization::FitsDocument)
  @tools        = options.fetch(:ch12n_tool, :fits)
end

Instance Attribute Details

#mappingObject

Returns the value of attribute mapping.



13
14
15
# File 'lib/hydra/works/services/characterization_service.rb', line 13

def mapping
  @mapping
end

#objectObject

Returns the value of attribute object.



13
14
15
# File 'lib/hydra/works/services/characterization_service.rb', line 13

def object
  @object
end

#parser_classObject

Returns the value of attribute parser_class.



13
14
15
# File 'lib/hydra/works/services/characterization_service.rb', line 13

def parser_class
  @parser_class
end

#sourceObject

Returns the value of attribute source.



13
14
15
# File 'lib/hydra/works/services/characterization_service.rb', line 13

def source
  @source
end

#toolsObject

Returns the value of attribute tools.



13
14
15
# File 'lib/hydra/works/services/characterization_service.rb', line 13

def tools
  @tools
end

Class Method Details

.run(object, source = nil, options = {}) ⇒ Object

Parameters:

  • object (Hydra::PCDM::File)

    which has properties to recieve characterization values.

  • source (String, File) (defaults to: nil)

    for characterization to be run on. File object or path on disk. If none is provided, it will assume the binary content already present on the object.

  • options (Hash) (defaults to: {})

    to be passed to characterization. parser_mapping:, parser_class:, tools:



9
10
11
# File 'lib/hydra/works/services/characterization_service.rb', line 9

def self.run(object, source = nil, options = {})
  new(object, source, options).characterize
end

Instance Method Details

#characterizeObject

Get given source into form that can be passed to Hydra::FileCharacterization Use Hydra::FileCharacterization to extract metadata (an OM XML document) Get the terms (and their values) from the extracted metadata Assign the values of the terms to the properties of the object



27
28
29
30
31
32
# File 'lib/hydra/works/services/characterization_service.rb', line 27

def characterize
  content = source_to_content
  extracted_md = (content)
  terms = (extracted_md)
  (terms)
end