Class: HXL::HXLTableSpec
- Inherits:
-
Object
- Object
- HXL::HXLTableSpec
- Defined in:
- lib/hxl/hxl_table_spec.rb
Instance Attribute Summary collapse
-
#col_specs ⇒ Object
readonly
Returns the value of attribute col_specs.
Instance Method Summary collapse
- #get_disaggregation_count ⇒ Object
- #get_raw_position(disaggregation_position) ⇒ Object
- #hxl_headers ⇒ Object
-
#initialize ⇒ HXLTableSpec
constructor
Table metadata for parsing a HXL dataset.
- #push(col_spec) ⇒ Object
Constructor Details
#initialize ⇒ HXLTableSpec
Table metadata for parsing a HXL dataset
7 8 9 |
# File 'lib/hxl/hxl_table_spec.rb', line 7 def initialize @col_specs = [] end |
Instance Attribute Details
#col_specs ⇒ Object (readonly)
Returns the value of attribute col_specs.
3 4 5 |
# File 'lib/hxl/hxl_table_spec.rb', line 3 def col_specs @col_specs end |
Instance Method Details
#get_disaggregation_count ⇒ Object
31 32 33 |
# File 'lib/hxl/hxl_table_spec.rb', line 31 def get_disaggregation_count (@col_specs.select { |col_spec| col_spec.fixed_column }).length end |
#get_raw_position(disaggregation_position) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/hxl/hxl_table_spec.rb', line 35 def get_raw_position(disaggregation_position) @col_specs.each_with_index do |col_spec, i| disaggregation_position -= 1 if col_spec.fixed_column return i if disaggregation_position < 0 end return -1 end |
#hxl_headers ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hxl/hxl_table_spec.rb', line 15 def hxl_headers headers = [] seen_fixed = false @col_specs.each do |spec| if spec.fixed_column && !seen_fixed headers.push spec.fixed_column.hxl_tag headers.push spec.column.hxl_tag unless spec.column.hxl_tag.nil? seen_fixed = true elsif !spec.fixed_column headers.push spec.column.hxl_tag unless spec.column.hxl_tag.nil? end end headers end |
#push(col_spec) ⇒ Object
11 12 13 |
# File 'lib/hxl/hxl_table_spec.rb', line 11 def push(col_spec) @col_specs.push col_spec end |