class RubyXL::GenericStorageObject
def self.parse_file(dirpath, file_path = nil)
def self.parse_file(dirpath, file_path = nil) file_path ||= self.xlsx_path obj = self.new(file_path) case dirpath when String then full_path = File.join(dirpath, file_path) return nil unless File.exist?(full_path) obj.data = File.open(full_path, 'r') { |f| f.read } when Zip::File then file_path = file_path.relative_path_from(::Pathname.new("/")) if file_path.absolute? # Zip doesn't like absolute paths. entry = dirpath.find_entry(file_path) return nil if entry.nil? obj.data = entry.get_input_stream { |f| f.read } end obj end
def add_to_zip(zip_stream)
def add_to_zip(zip_stream) return if @data.nil? path = self.xlsx_path path = path.relative_path_from(Pathname.new("/")) if path.absolute? # Zip doesn't like absolute paths. zip_stream.put_next_entry(path) zip_stream.write(@data) end
def initialize(file_path)
def initialize(file_path) @xlsx_path = file_path @data = nil @generic_storage = [] end