Class: Creek::Book

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Book

Returns a new instance of Book.



12
13
14
15
16
17
18
19
20
# File 'lib/creek/book.rb', line 12

def initialize path, options = {}
  check_file_extension = options.fetch(:check_file_extension, true)
  if check_file_extension
    extension = File.extname(options[:original_filename] || path).downcase
    raise 'Not a valid file format.' unless (['.xlsx', '.xlsm'].include? extension)
  end
  @files          = Zip::File.open path
  @shared_strings = SharedStrings.new(self)
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



8
9
10
# File 'lib/creek/book.rb', line 8

def files
  @files
end

#shared_stringsObject (readonly)

Returns the value of attribute shared_strings.



8
9
10
# File 'lib/creek/book.rb', line 8

def shared_strings
  @shared_strings
end

#sheetsObject (readonly)

Returns the value of attribute sheets.



8
9
10
# File 'lib/creek/book.rb', line 8

def sheets
  @sheets
end

Instance Method Details

#closeObject



34
35
36
# File 'lib/creek/book.rb', line 34

def close
  @files.close
end

#style_typesObject



30
31
32
# File 'lib/creek/book.rb', line 30

def style_types
  @style_types ||= Creek::Styles.new(self).style_types
end