Class: FileReader::Excel
- Inherits:
-
Connector::ExcelReadConnector
- Object
- Connector::ExcelReadConnector
- FileReader::Excel
- Defined in:
- lib/mylookup/reader.rb
Overview
Contains the functionalities of reading Excel data
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(path, sht_name, col_name) ⇒ Excel
constructor
A new instance of Excel.
- #read(match: {}, hide: {}, q_meth: :find) ⇒ Object
Methods inherited from Connector::ExcelReadConnector
#column_exists?, #sheet_exists?
Constructor Details
#initialize(path, sht_name, col_name) ⇒ Excel
Returns a new instance of Excel.
11 12 13 14 15 16 |
# File 'lib/mylookup/reader.rb', line 11 def initialize(path, sht_name, col_name) super(path) @sht = @wb.sheet(sht_name) @col = col_name @data = nil end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/mylookup/reader.rb', line 9 def data @data end |
Instance Method Details
#read(match: {}, hide: {}, q_meth: :find) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mylookup/reader.rb', line 18 def read(match: {}, hide: {}, q_meth: :find) aoa = @sht.parse(@col.to_sym => @col) @data = aoa.collect { |item| item[@col.to_sym].to_s.downcase } @data = @data.uniq return "Excel Data contains #{@data.size} row(s)\nExcel First Record => #{@data[0]}" end |