Class: TaliaCore::DataTypes::FileRecord

Inherits:
DataRecord
  • Object
show all
Extended by:
DataLoader::ClassMethods, TaliaCore::DataTypes::FileStore::ClassMethods, IipLoader, PathHelpers::ClassMethods, TempFileHandling::ClassMethods, TaliaUtil::IoHelper
Includes:
DataLoader, FileStore, PathHelpers, TempFileHandling
Defined in:
lib/talia_core/data_types/file_record.rb

Overview

Base class for all data records that use a plain file for data storage

Direct Known Subclasses

IipData, ImageData, PdfData, SimpleText, XmlData

Instance Attribute Summary

Attributes inherited from DataRecord

#temp_path

Instance Method Summary collapse

Methods included from TaliaCore::DataTypes::FileStore::ClassMethods

find_or_create_and_assign_file

Methods included from PathHelpers::ClassMethods

data_path, extract_filename, tempfile_path

Methods included from TempFileHandling::ClassMethods

copy_to_temp_file, create_tempfile_path, write_to_temp_file

Methods included from DataLoader::ClassMethods

create_from_url

Methods included from IipLoader

convert_original?, create_from_files, create_from_stream, create_iip, open_original_image, open_original_image_file, open_original_image_stream, orig_location, prepare_image_from_existing!

Methods included from TaliaUtil::IoHelper

base_for, file_url, open_from_url, open_generic

Methods included from TempFileHandling

#copy_to_temp_file, #random_tempfile_filename, #temp_data, #temp_data=, #temp_path, #temp_path=, #temp_paths, #write_to_temp_file

Methods included from PathHelpers

#data_directory, #data_path, #extract_filename, #file_path, #full_filename, #static_path, #tempfile_path

Methods included from FileStore

#all_text, #assign_type, #create_from_data, #create_from_file, #file, #file=, #is_file_open?, #write_file_after_save

Methods inherited from DataRecord

#content_string, #extract_mime_type, find_by_type_and_location!, find_data_records, #mime_type

Instance Method Details

#all_bytesObject

returns all bytes in the object as an array



27
28
29
# File 'lib/talia_core/data_types/file_record.rb', line 27

def all_bytes
  read_all_bytes
end

#get_byte(close_after_single_read = false) ⇒ Object

returns the next byte from the object, or nil at EOS



32
33
34
# File 'lib/talia_core/data_types/file_record.rb', line 32

def get_byte(close_after_single_read=false)
  next_byte(close_after_single_read)
end

#positionObject

returns the current position of the read cursor (binary access)



37
38
39
# File 'lib/talia_core/data_types/file_record.rb', line 37

def position
  return (@position != nil) ? @position : 0
end

#resetObject

reset the cursor to the initial state



42
43
44
# File 'lib/talia_core/data_types/file_record.rb', line 42

def reset
  set_position(0)
end

#seek(new_position) ⇒ Object

set the new position of the reding cursors



47
48
49
# File 'lib/talia_core/data_types/file_record.rb', line 47

def seek(new_position)
  set_position(new_position)
end

#sizeObject

returns the size of the object in bytes



52
53
54
# File 'lib/talia_core/data_types/file_record.rb', line 52

def size
  data_size
end