Class: PascalFile

Inherits:
DSKFile show all
Defined in:
lib/PascalFile.rb

Overview

Pascal file

Constant Summary collapse

PASCAL_FILE_TYPES =
[:untyped,:xdsk,:code,:text,:info,:data,:graf,:foto,:securedir]

Constants inherited from DSKFile

DSKFile::APPLESOFT_TOKENS

Instance Attribute Summary collapse

Attributes inherited from DSKFile

#contents, #filename

Instance Method Summary collapse

Methods inherited from DSKFile

#==, #buffer_as_applesoft_file, #hex_dump, #length_in_sectors, #to_ascii

Constructor Details

#initialize(filename, contents, file_type) ⇒ PascalFile

Returns a new instance of PascalFile.



12
13
14
15
16
17
# File 'lib/PascalFile.rb', line 12

def initialize(filename,contents,file_type)
	raise "filename too long - #{filename}" unless filename.length<=15
	@filename=filename
	@contents=contents
	@file_type=PASCAL_FILE_TYPES[file_type]
end

Instance Attribute Details

#file_typeObject

Returns the value of attribute file_type.



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

def file_type
  @file_type
end

Instance Method Details

#can_be_picture?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/PascalFile.rb', line 29

def can_be_picture?
	
	file_type==:foto && HGR.can_be_hgr_screen?(@contents)
end

#file_extensionObject



25
26
27
# File 'lib/PascalFile.rb', line 25

def file_extension
	return "."+@file_type.downcase
end

#to_png(pallete_mode = :amber) ⇒ Object



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

def to_png(pallete_mode=:amber)
	HGR.buffer_to_png(@contents,pallete_mode)
end

#to_sObject



19
20
21
22
23
# File 'lib/PascalFile.rb', line 19

def to_s
	s=""
	@contents.each_byte{|b| s<<(b%0x80).chr.tr(0x0D.chr,"\n")}
	s
end