Class: ONIX::Series

Inherits:
Object
  • Object
show all
Includes:
ROXML
Defined in:
lib/onix/series.rb

Instance Method Summary collapse

Constructor Details

#initializeSeries

Returns a new instance of Series.



12
13
14
# File 'lib/onix/series.rb', line 12

def initialize
  self.series_identifiers = []
end

Instance Method Details

#issnObject

retrieve the issn



27
28
29
# File 'lib/onix/series.rb', line 27

def issn
  series_identifier(2).try(:id_value)
end

#issn=(id) ⇒ Object

set a new issn



32
33
34
# File 'lib/onix/series.rb', line 32

def issn=(id)
  series_identifier_set(2, id)
end

#proprietary_series_idObject

retrieve the proprietary series ID



17
18
19
# File 'lib/onix/series.rb', line 17

def proprietary_series_id
  series_identifier(1).try(:id_value)
end

#proprietary_series_id=(id) ⇒ Object

set a new proprietary series ID



22
23
24
# File 'lib/onix/series.rb', line 22

def proprietary_series_id=(id)
  series_identifier_set(1, id)
end

#series_identifier(type) ⇒ Object

retrieve the value of a particular ID



37
38
39
# File 'lib/onix/series.rb', line 37

def series_identifier(type)
  identifier = series_identifiers.find { |id| id.series_id_type == type }
end

#series_identifier_set(type, value) ⇒ Object

set the value of a particular ID



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/onix/series.rb', line 42

def series_identifier_set(type, value)
  series_indentifier_id = series_identifiers.find { |id| id.series_id_type == type }

  # create a new series identifier record if we need to
  if series_indentifier_id.nil?
    series_indentifier_id = ONIX::SeriesIdentifier.new
  end

  series_indentifier_id.series_id_type = type
  series_indentifier_id.id_value = value

  series_identifiers << series_indentifier_id
end