Class: ExcelXml::Worksheet::Parser
- Inherits:
-
Object
- Object
- ExcelXml::Worksheet::Parser
- Defined in:
- lib/excelxml/worksheet.rb
Instance Attribute Summary collapse
-
#header_row_index ⇒ Object
Returns the value of attribute header_row_index.
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
- #index_to_header_map ⇒ Object
-
#initialize(worksheet) ⇒ Parser
constructor
A new instance of Parser.
- #is_header?(row_number, fields) ⇒ Boolean
-
#mandatory_columns ⇒ Object
Override methods.
- #rows ⇒ Object
Constructor Details
#initialize(worksheet) ⇒ Parser
Returns a new instance of Parser.
39 40 41 |
# File 'lib/excelxml/worksheet.rb', line 39 def initialize worksheet @worksheet = worksheet end |
Instance Attribute Details
#header_row_index ⇒ Object
Returns the value of attribute header_row_index.
37 38 39 |
# File 'lib/excelxml/worksheet.rb', line 37 def header_row_index @header_row_index end |
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
36 37 38 |
# File 'lib/excelxml/worksheet.rb', line 36 def worksheet @worksheet end |
Instance Method Details
#index_to_header_map ⇒ Object
51 52 53 |
# File 'lib/excelxml/worksheet.rb', line 51 def index_to_header_map @index_to_header_map ||= @worksheet.rows[header_row_index].collect {|h| h ? h.strip : nil } end |
#is_header?(row_number, fields) ⇒ Boolean
63 64 65 66 |
# File 'lib/excelxml/worksheet.rb', line 63 def is_header? row_number, fields return true if mandatory_columns.all? {|mc| fields.any? {|f| next unless f; f.match mc } } return false end |
#mandatory_columns ⇒ Object
Override methods
59 60 61 |
# File 'lib/excelxml/worksheet.rb', line 59 def mandatory_columns [] end |