Class: BerkeleyLibrary::Marc::FieldInfo::VarFields::VarFieldList
- Inherits:
-
Object
- Object
- BerkeleyLibrary::Marc::FieldInfo::VarFields::VarFieldList
- Includes:
- Obsolescible, Enumerable
- Defined in:
- lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb
Overview
A list of variable fields grouped into sections.
Constant Summary
Constants included from Obsolescible
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Each section in this list.
-
#initialize(desc:, sections:) ⇒ VarFieldList
constructor
A new instance of VarFieldList.
- #reject_obsoletes ⇒ Object
-
#size ⇒ Object
The number of sections in this list.
-
#to_s ⇒ Object
see Object#to_s.
Methods included from Obsolescible
#_reject_obsolete, #empty?, #obsolete?
Constructor Details
#initialize(desc:, sections:) ⇒ VarFieldList
Returns a new instance of VarFieldList.
15 16 17 18 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 15 def initialize(desc:, sections:) @desc = desc @sections = sections end |
Instance Attribute Details
#desc ⇒ Object (readonly)
Returns the value of attribute desc.
13 14 15 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 13 def desc @desc end |
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
13 14 15 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 13 def sections @sections end |
Instance Method Details
#each ⇒ Enumerator<Section> #each {|s| ... } ⇒ Object
Each section in this list.
27 28 29 30 31 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 27 def each(&block) return to_enum(:each) unless block_given? sections.each { |section| section.each(&block) } end |
#reject_obsoletes ⇒ Object
39 40 41 42 43 44 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 39 def reject_obsoletes VarFieldList.new( desc: desc, sections: _reject_obsolete(sections) ) end |
#size ⇒ Object
The number of sections in this list.
34 35 36 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 34 def size sections.sum(&:size) end |
#to_s ⇒ Object
see Object#to_s
47 48 49 |
# File 'lib/berkeley_library/marc/field_info/var_fields/var_field_list.rb', line 47 def to_s sections.map(&:to_s).join("\n") end |