Class: ONIX::Entity

Inherits:
SubsetDSL show all
Includes:
EntityHelper, GlnMethods
Defined in:
lib/onix/entity.rb

Direct Known Subclasses

Agent, Imprint, Publisher, Supplier

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GlnMethods

#gln, #gln_identifier

Methods inherited from SubsetDSL

_ancestor_registered_scopes, _ancestors_registered_elements, ancestor_registered_scopes, ancestors_registered_elements, element, elements, get_class, ref_to_short, registered_elements, registered_scopes, scope, short_to_ref, #unsupported

Methods inherited from Subset

parse, #tag_match, tag_match, #unsupported

Constructor Details

#initializeEntity

Returns a new instance of Entity.



19
20
21
22
# File 'lib/onix/entity.rb', line 19

def initialize
  super
  @identifiers = []
end

Instance Attribute Details

#identifiersObject

entity Identifier list



14
15
16
# File 'lib/onix/entity.rb', line 14

def identifiers
  @identifiers
end

#nameObject

entity name



10
11
12
# File 'lib/onix/entity.rb', line 10

def name
  @name
end

#roleObject

entity role



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

def role
  @role
end

Class Method Details

.identifier_classObject



57
58
59
# File 'lib/onix/entity.rb', line 57

def self.identifier_class
  nil
end

.identifier_tagObject



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

def self.identifier_tag
  "#{self.prefix}Identifier"
end

.name_tagObject



28
29
30
# File 'lib/onix/entity.rb', line 28

def self.name_tag
  "#{self.prefix}Name"
end

.prefixObject



54
55
# File 'lib/onix/entity.rb', line 54

def self.prefix
end

.role_classObject



61
62
63
# File 'lib/onix/entity.rb', line 61

def self.role_class
  nil
end

.role_tagObject



24
25
26
# File 'lib/onix/entity.rb', line 24

def self.role_tag
  "#{self.prefix}Role"
end

Instance Method Details

#parse(n) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/onix/entity.rb', line 36

def parse(n)
  super
  n.children.each do |t|
    case t
      when tag_match(self.class.name_tag)
        @name=t.text
      when tag_match(self.class.role_tag)
        if self.class.role_class
          @role=self.class.role_class.parse(t)
        end
      when tag_match(self.class.identifier_tag)
        if self.class.identifier_class
          @identifiers << self.class.identifier_class.parse(t)
        end
    end
  end
end