Module: BerkeleyLibrary::Marc::FieldInfo::VarFields::Obsolescible
- Included in:
- IndDef, IndValDef, InstrumentOrVoicesCode, Section, SubfieldDef, SubfieldVal, VarFieldDef, VarFieldList
- Defined in:
- lib/berkeley_library/marc/field_info/var_fields/obsolescible.rb
Overview
Mixin for possibly-obsolete members of a MARC field info tree
Constant Summary collapse
- OBSOLETE =
Description marker for obsolete elements in a MARC field list
'[OBSOLETE]'.freeze
Instance Method Summary collapse
-
#_reject_obsolete(obs) ⇒ Array<Obsolescible>
protected
Utility method for deep-rejecting obsolete members and their obsolete descendants from a list of Obsolescibles.
-
#empty? ⇒ Boolean
Return true if this object's subtree is empty, false if this object is a leaf node or has a non-empty subtree.
-
#obsolete? ⇒ Boolean
Return true if this Obsolescible's description marks it as obsolete, false otherwise.
-
#reject_obsoletes ⇒ Object
Return a copy of this object with all obsolete nodes in its subtree removed, or the object itself if it has no descendants.
Instance Method Details
#_reject_obsolete(obs) ⇒ Array<Obsolescible> (protected)
Utility method for deep-rejecting obsolete members and their obsolete descendants from a list of Obsolescibles.
44 45 46 47 48 49 50 |
# File 'lib/berkeley_library/marc/field_info/var_fields/obsolescible.rb', line 44 def _reject_obsolete(obs) obs.lazy .reject(&:obsolete?) .map(&:reject_obsoletes) .reject(&:empty?) .to_a end |
#empty? ⇒ Boolean
Return true if this object's subtree is empty, false if this object is a leaf node or has a non-empty subtree.
32 33 34 35 |
# File 'lib/berkeley_library/marc/field_info/var_fields/obsolescible.rb', line 32 def empty? # default implementation for leaf nodes false end |
#obsolete? ⇒ Boolean
Return true if this Obsolescible's description marks it as obsolete, false otherwise
14 15 16 17 18 |
# File 'lib/berkeley_library/marc/field_info/var_fields/obsolescible.rb', line 14 def obsolete? return unless respond_to?(:desc) desc&.include?(OBSOLETE) end |
#reject_obsoletes ⇒ Object
Return a copy of this object with all obsolete nodes in its subtree removed, or the object itself if it has no descendants. Note that in the (pathological) situation of a non-obsolete, non-leaf node with no non-obsolete descendants, an empty object will be returned.
25 26 27 28 |
# File 'lib/berkeley_library/marc/field_info/var_fields/obsolescible.rb', line 25 def reject_obsoletes # default implementation for leaf nodes self end |