Class: BerkeleyLibrary::TIND::Export::ColumnGroupList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/berkeley_library/tind/export/column_group_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(exportable_only: false) ⇒ ColumnGroupList


Initializer



17
18
19
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 17

def initialize(exportable_only: false)
  @exportable_only = exportable_only
end

Instance Method Details

#add_data_fields(marc_record, row) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 42

def add_data_fields(marc_record, row)
  # TODO: what about control fields?
  marc_record.data_fields_by_tag.each do |tag, data_fields|
    next unless can_export_tag(tag)
    next if data_fields.empty?

    add_fields_at(data_fields, row)
  end
rescue StandardError => e
  raise Export::ExportException, "Error adding MARC record #{marc_record.record_id} at row #{row}: #{e.message}"
end

#all_groupsObject


Misc. instance methods



31
32
33
34
35
36
37
38
39
40
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 31

def all_groups
  # NOTE: this isn't ||= because we only cache on #freeze
  @all_groups || begin
    all_tags = column_groups_by_tag.keys.sort
    all_tags.each_with_object([]) do |tag, groups|
      tag_column_groups = column_groups_by_tag[tag]
      groups.concat(tag_column_groups)
    end
  end
end

#each(&block) ⇒ Object


Enumerable



57
58
59
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 57

def each(&block)
  all_groups.each(&block)
end

#exportable_only?Boolean


Accessors

Returns:

  • (Boolean)


24
25
26
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 24

def exportable_only?
  @exportable_only
end

#freezeObject


Object overrides



64
65
66
67
68
69
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 64

def freeze
  column_groups_by_tag.each_value(&:freeze)
  column_groups_by_tag.freeze
  @all_groups ||= all_groups.freeze
  self
end

#frozen?Boolean

Returns:

  • (Boolean)


71
72
73
74
# File 'lib/berkeley_library/tind/export/column_group_list.rb', line 71

def frozen?
  column_groups_by_tag.frozen? &&
    @all_groups && @all_groups.frozen?
end