Class: ROF::Translators::FedoraToRof

Inherits:
ROF::Translator show all
Defined in:
lib/rof/translators/fedora_to_rof.rb

Overview

Responsible for translating Fedora PIDs to ROF objects

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pids, config = {}) ⇒ FedoraToRof

Returns a new instance of FedoraToRof.



21
22
23
24
25
26
# File 'lib/rof/translators/fedora_to_rof.rb', line 21

def initialize(pids, config = {})
  @pids = pids
  @fedora_connection_information = config.fetch(:fedora_connection_information)
  @config = config
  connect_to_fedora!
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



27
28
29
# File 'lib/rof/translators/fedora_to_rof.rb', line 27

def config
  @config
end

#connectionObject (readonly)

Returns the value of attribute connection.



27
28
29
# File 'lib/rof/translators/fedora_to_rof.rb', line 27

def connection
  @connection
end

#fedora_connection_informationObject (readonly)

Returns the value of attribute fedora_connection_information.



27
28
29
# File 'lib/rof/translators/fedora_to_rof.rb', line 27

def fedora_connection_information
  @fedora_connection_information
end

#pidsObject (readonly)

Returns the value of attribute pids.



27
28
29
# File 'lib/rof/translators/fedora_to_rof.rb', line 27

def pids
  @pids
end

Class Method Details

.call(pids, config = {}) ⇒ Hash

Returns The ROF representation of teh Fedora objects.

Parameters:

  • pids (Array)
    • Fedora PIDs

  • config (Hash) (defaults to: {})
    • Hash with symbol keys

Options Hash (config):

  • :fedora_connection_information (Hash)
    • The Hash that contains the connection information for Fedora

Returns:

  • (Hash)

    The ROF representation of teh Fedora objects

See Also:

  • Rubydora.connect


17
18
19
# File 'lib/rof/translators/fedora_to_rof.rb', line 17

def self.call(pids, config = {})
  new(pids, config).to_rof
end

Instance Method Details

#to_rofObject



37
38
39
40
41
42
# File 'lib/rof/translators/fedora_to_rof.rb', line 37

def to_rof
  # wrap the objects inside a JSON list
  pids.map do |pid|
    PidToRofElement.new(pid, connection, config).convert
  end
end