Class: Elibri::ONIX::Release_3_0::Subject

Inherits:
Object
  • Object
show all
Includes:
HashId
Defined in:
lib/elibri_onix/onix_3_0/subject.rb

Constant Summary collapse

ATTRIBUTES =
[
  :scheme_identifier, :scheme_name, :scheme_version, :code, :heading_text, :main_subject
]
RELATIONS =
[]

Constants included from HashId

HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashId

#calculate_hash, #eid

Constructor Details

#initialize(data) ⇒ Subject

Returns a new instance of Subject.



23
24
25
26
27
28
29
30
31
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 23

def initialize(data)
  @to_xml = data.to_s
  @scheme_identifier = data.xpath('xmlns:SubjectSchemeIdentifier').try(:text).try(:to_i)
  @scheme_name = data.xpath('xmlns:SubjectSchemeName').try(:text)
  @scheme_version = data.xpath('xmlns:SubjectSchemeVersion').try(:text)
  @code = data.xpath('xmlns:SubjectCode').try(:text)
  @heading_text = data.xpath('xmlns:SubjectHeadingText').try(:text)
  @main_subject = data.xpath('xmlns:MainSubject').blank? ? nil : '' 
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def code
  @code
end

#heading_textObject

Returns the value of attribute heading_text.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def heading_text
  @heading_text
end

#main_subjectObject

Returns the value of attribute main_subject.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def main_subject
  @main_subject
end

#scheme_identifierObject

Returns the value of attribute scheme_identifier.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def scheme_identifier
  @scheme_identifier
end

#scheme_nameObject

Returns the value of attribute scheme_name.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def scheme_name
  @scheme_name
end

#scheme_versionObject

Returns the value of attribute scheme_version.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def scheme_version
  @scheme_version
end

#to_xmlObject

Returns the value of attribute to_xml.



19
20
21
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 19

def to_xml
  @to_xml
end

Instance Method Details

#idObject

def eid

  @code
end


41
42
43
44
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 41

def id
  Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
  eid
end

#main_subject?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 33

def main_subject?
  @main_subject == ''
end