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
-
#related_subjects ⇒ Object
readonly
Returns the value of attribute related_subjects.
-
#subject_of ⇒ Object
readonly
Returns the value of attribute subject_of.
Class Method Summary collapse
Instance Method Summary collapse
- #add_related_subject(thing) ⇒ Object
- #add_subject_of(work) ⇒ Object
- #remove_related_subject(thing) ⇒ Object
- #remove_subject_of(work) ⇒ Object
Instance Attribute Details
#related_subjects ⇒ Object (readonly)
Returns the value of attribute related_subjects.
162 163 164 |
# File 'lib/frbr/groups.rb', line 162 def @related_subjects end |
#subject_of ⇒ Object (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
#add_related_subject(thing) ⇒ Object
190 191 192 193 194 195 |
# File 'lib/frbr/groups.rb', line 190 def (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.(self) unless thing. && thing..index(self) end |
#add_subject_of(work) ⇒ Object
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 |
#remove_related_subject(thing) ⇒ Object
197 198 199 200 201 |
# File 'lib/frbr/groups.rb', line 197 def (thing) return unless @related_subjects @related_subjects.delete(thing) thing.(self) if thing. && thing..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 |