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
- #has_header?(header) ⇒ Boolean
- #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
#has_header?(header) ⇒ Boolean
51 52 53 |
# File 'lib/excelxml/worksheet.rb', line 51 def has_header? header index_to_header_map.find {|e| e.match header } end |
#index_to_header_map ⇒ Object
55 56 57 |
# File 'lib/excelxml/worksheet.rb', line 55 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
67 68 69 70 |
# File 'lib/excelxml/worksheet.rb', line 67 def is_header? row_number, fields return true if mandatory_columns.all? {|mc| fields.compact.any? {|f| f.match mc } } return false end |
#mandatory_columns ⇒ Object
Override methods
63 64 65 |
# File 'lib/excelxml/worksheet.rb', line 63 def mandatory_columns [] end |