Class: BerkeleyLibrary::TIND::Export::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/berkeley_library/tind/export/column.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_group, col_in_group) ⇒ Column

Initializes a new column

Parameters:

  • column_group (ColumnGroup)

    the group containing this column

  • col_in_group (Integer)

    the index of this column in the group



18
19
20
21
# File 'lib/berkeley_library/tind/export/column.rb', line 18

def initialize(column_group, col_in_group)
  @column_group = column_group
  @col_in_group = col_in_group
end

Instance Attribute Details

#col_in_groupInteger (readonly)

Returns the index of this column in the group.

Returns:

  • (Integer)

    the index of this column in the group



12
13
14
# File 'lib/berkeley_library/tind/export/column.rb', line 12

def col_in_group
  @col_in_group
end

#column_groupColumnGroup (readonly)

Returns the group containing this column.

Returns:



9
10
11
# File 'lib/berkeley_library/tind/export/column.rb', line 9

def column_group
  @column_group
end

Instance Method Details

#can_edit?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
# File 'lib/berkeley_library/tind/export/column.rb', line 36

def can_edit?
  @can_edit ||= Filter.can_edit?(
    column_group.tag,
    column_group.ind1,
    column_group.ind2,
    subfield_code
  )
end

#each_value(include_header: false) {|header| ... } ⇒ Object

Yields:



45
46
47
48
49
50
# File 'lib/berkeley_library/tind/export/column.rb', line 45

def each_value(include_header: false)
  return to_enum(:each_value, include_header: include_header) unless block_given?

  yield header if include_header
  column_group.row_count.times { |row| yield value_at(row) }
end

#headerObject



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

def header
  # NOTE: that TIND "-#" suffixes must be unique by tag, not tag + ind1 + ind2
  @header ||= "#{column_group.prefix}#{subfield_code}-#{1 + column_group.index_in_tag}"
end

#subfield_codeObject



28
29
30
# File 'lib/berkeley_library/tind/export/column.rb', line 28

def subfield_code
  @subfield_code ||= column_group.subfield_codes[col_in_group]
end

#value_at(row) ⇒ Object



32
33
34
# File 'lib/berkeley_library/tind/export/column.rb', line 32

def value_at(row)
  column_group.value_at(row, col_in_group)
end