Module: FRBR::Group3

Included in:
Concept, CorporateBody, Event, Expression, Family, Item, Manifestation, Object, Person, Place, Work
Defined in:
lib/frbr/groups.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

Returns the value of attribute related_subjects.



162
163
164
# File 'lib/frbr/groups.rb', line 162

def related_subjects
  @related_subjects
end

#subject_ofObject (readonly)

Returns the value of attribute subject_of.



162
163
164
# File 'lib/frbr/groups.rb', line 162

def subject_of
  @subject_of
end

Class Method Details

.check_frbr_validity(o, mod_name) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/frbr/groups.rb', line 164

def self.check_frbr_validity(o, mod_name)

  unless mod_name == "FRBR::Group3"
    entities = [FRBR::Work, FRBR::Expression, FRBR::Manifestation, FRBR::Item,
      FRBR::Person, FRBR::CorporateBody, FRBR::Family, 
      FRBR::Concept, FRBR::Event, FRBR::Object, FRBR::Place]
    entities.delete(Kernel.constant(mod_name))
    entities.each do |e|
      raise TypeError, "#{mod_name} cannot also be a #{e.to_s}" if o.is_a?(e)
    end
  end
end

Instance Method Details

Raises:

  • (ArgumentError)


190
191
192
193
194
195
# File 'lib/frbr/groups.rb', line 190

def add_related_subject(thing)
  raise ArgumentError, "Group 3 entities can only be related to other Group 3 entities" unless thing.is_a?(FRBR::Group3)
  @related_subjects ||= []
  @related_subjects << thing unless @related_subjects && @related_subjects.index(thing)
  thing.add_related_subject(self) unless thing.related_subjects && thing.related_subjects.index(self)
end

#add_subject_of(work) ⇒ Object

Raises:

  • (ArgumentError)


177
178
179
180
181
182
# File 'lib/frbr/groups.rb', line 177

def add_subject_of(work)
  raise ArgumentError, "Group 3 entities can only be subjects of Works" unless work.is_a?(FRBR::Work)
  @subject_of ||= []
  @subject_of << work unless @subject_of.index(work)
  work.add_subject(self) unless work.subjects && work.subjects.index(self)
end


197
198
199
200
201
# File 'lib/frbr/groups.rb', line 197

def remove_related_subject(thing)
  return unless @related_subjects
  @related_subjects.delete(thing)
  thing.remove_related_subject(self) if thing.related_subjects && thing.related_subjects.index(self)
end

#remove_subject_of(work) ⇒ Object



184
185
186
187
188
# File 'lib/frbr/groups.rb', line 184

def remove_subject_of(work)
  return unless @subject_of
  @subject_of.delete(work) if @subject_of && @subject_of.index(work)
  work.remove_subject(self) if work.subjects && work.subjects.index(self)
end