Class: BerkeleyLibrary::Marc::FieldInfo::VarFields::Section
- Inherits:
-
Object
- Object
- BerkeleyLibrary::Marc::FieldInfo::VarFields::Section
- Includes:
- Obsolescible, Enumerable
- Defined in:
- lib/berkeley_library/marc/field_info/var_fields/section.rb
Overview
A section of a MARC field list
Constant Summary
Constants included from Obsolescible
Instance Attribute Summary collapse
-
#desc ⇒ Object
readonly
Returns the value of attribute desc.
-
#var_fields ⇒ Object
readonly
Returns the value of attribute var_fields.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
Each variable field definition in this section.
-
#empty? ⇒ Boolean
Returns true if this section contains no variable fields.
-
#initialize(desc:, var_fields:) ⇒ Section
constructor
A new instance of Section.
- #reject_obsoletes ⇒ Object
-
#size ⇒ Object
The number of variable fields in this section.
-
#to_s ⇒ Object
see Object#to_s.
Methods included from Obsolescible
Constructor Details
#initialize(desc:, var_fields:) ⇒ Section
Returns a new instance of Section.
16 17 18 19 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 16 def initialize(desc:, var_fields:) @desc = desc @var_fields = var_fields 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/section.rb', line 13 def desc @desc end |
#var_fields ⇒ Object (readonly)
Returns the value of attribute var_fields.
14 15 16 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 14 def var_fields @var_fields end |
Instance Method Details
#each ⇒ Enumerator<VarFieldDef> #each {|vf| ... } ⇒ Object
Each variable field definition in this section.
28 29 30 31 32 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 28 def each(&block) return to_enum(:each) unless block_given? var_fields.each(&block) end |
#empty? ⇒ Boolean
Returns true if this section contains no variable fields.
40 41 42 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 40 def empty? var_fields.empty? end |
#reject_obsoletes ⇒ Object
45 46 47 48 49 50 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 45 def reject_obsoletes Section.new( desc: desc, var_fields: _reject_obsolete(var_fields) ) end |
#size ⇒ Object
The number of variable fields in this section.
35 36 37 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 35 def size var_fields.size end |
#to_s ⇒ Object
see Object#to_s
53 54 55 56 57 |
# File 'lib/berkeley_library/marc/field_info/var_fields/section.rb', line 53 def to_s blocks = ["--#{desc}--"] blocks.concat(var_fields.map(&:to_s)) blocks.join("\n") end |