Class: SimpleXlsxReader::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_xlsx_reader.rb

Defined Under Namespace

Classes: Mapper, Sheet, Xml

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path) ⇒ Document

Returns a new instance of Document.



35
36
37
# File 'lib/simple_xlsx_reader.rb', line 35

def initialize(file_path)
  @file_path = file_path
end

Instance Attribute Details

#file_pathObject (readonly)

Returns the value of attribute file_path.



33
34
35
# File 'lib/simple_xlsx_reader.rb', line 33

def file_path
  @file_path
end

Instance Method Details

#sheetsObject



39
40
41
# File 'lib/simple_xlsx_reader.rb', line 39

def sheets
  @sheets ||= Mapper.new(xml).load_sheets
end

#to_hashObject



43
44
45
# File 'lib/simple_xlsx_reader.rb', line 43

def to_hash
  sheets.inject({}) {|acc, sheet| acc[sheet.name] = sheet.rows; acc}
end

#xmlObject



47
48
49
# File 'lib/simple_xlsx_reader.rb', line 47

def xml
  Xml.load(file_path)
end