Class: Elibri::ONIX::Release_3_0::Subject
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::Subject
- 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
-
#code ⇒ Object
Returns the value of attribute code.
-
#heading_text ⇒ Object
Returns the value of attribute heading_text.
-
#main_subject ⇒ Object
Returns the value of attribute main_subject.
-
#scheme_identifier ⇒ Object
Returns the value of attribute scheme_identifier.
-
#scheme_name ⇒ Object
Returns the value of attribute scheme_name.
-
#scheme_version ⇒ Object
Returns the value of attribute scheme_version.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
Instance Method Summary collapse
-
#id ⇒ Object
def eid @code end.
-
#initialize(data) ⇒ Subject
constructor
A new instance of Subject.
- #main_subject? ⇒ Boolean
Methods included from HashId
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
#code ⇒ Object
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_text ⇒ Object
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_subject ⇒ Object
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_identifier ⇒ Object
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_name ⇒ Object
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_version ⇒ Object
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_xml ⇒ Object
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
#id ⇒ Object
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
33 34 35 |
# File 'lib/elibri_onix/onix_3_0/subject.rb', line 33 def main_subject? @main_subject == '' end |