Class: BerkeleyLibrary::TIND::Export::Column
- Inherits:
-
Object
- Object
- BerkeleyLibrary::TIND::Export::Column
- Defined in:
- lib/berkeley_library/tind/export/column.rb
Instance Attribute Summary collapse
-
#col_in_group ⇒ Integer
readonly
The index of this column in the group.
-
#column_group ⇒ ColumnGroup
readonly
The group containing this column.
Instance Method Summary collapse
- #can_edit? ⇒ Boolean
- #each_value(include_header: false) {|header| ... } ⇒ Object
- #header ⇒ Object
-
#initialize(column_group, col_in_group) ⇒ Column
constructor
Initializes a new column.
- #subfield_code ⇒ Object
- #value_at(row) ⇒ Object
Constructor Details
#initialize(column_group, col_in_group) ⇒ Column
Initializes a new column
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_group ⇒ Integer (readonly)
Returns 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_group ⇒ ColumnGroup (readonly)
Returns the group containing this column.
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
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
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 |
#header ⇒ Object
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_code ⇒ Object
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 |