Class: CPMFile
Constant Summary
Constants inherited
from DSKFile
DSKFile::APPLESOFT_TOKENS
Instance Attribute Summary collapse
Attributes inherited from DSKFile
#contents, #filename
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from DSKFile
#==, #buffer_as_applesoft_file, #hex_dump, #length_in_sectors, #to_ascii
Constructor Details
#initialize(filename, contents) ⇒ CPMFile
Returns a new instance of CPMFile.
16
17
18
19
20
|
# File 'lib/CPMFile.rb', line 16
def initialize(filename,contents)
@filename,@file_type=CPMFile.split_filename(filename)
raise "invalid filename #{filename}" if @filename.nil?
@contents=contents
end
|
Instance Attribute Details
#file_type ⇒ Object
Returns the value of attribute file_type.
8
9
10
|
# File 'lib/CPMFile.rb', line 8
def file_type
@file_type
end
|
Class Method Details
.split_filename(filename) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/CPMFile.rb', line 9
def CPMFile.split_filename(filename)
filename=~/^([^.]{0,8})(\.([^.]{0,3}))?$/ partial_filename=$1
ext=$3
ext="" if ext.nil?
return [partial_filename,ext]
end
|
Instance Method Details
#can_be_picture? ⇒ Boolean
38
39
40
|
# File 'lib/CPMFile.rb', line 38
def can_be_picture?
file_type==:foto && HGR.can_be_hgr_screen?(@contents)
end
|
#file_extension ⇒ Object
34
35
36
|
# File 'lib/CPMFile.rb', line 34
def file_extension
return "."+@file_type.downcase
end
|
#full_filename ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/CPMFile.rb', line 22
def full_filename
if @file_type=="" then
@filename
else
"#{@filename}.#{@file_type}"
end
end
|
#to_png(pallete_mode = :amber) ⇒ Object
42
43
44
|
# File 'lib/CPMFile.rb', line 42
def to_png(pallete_mode=:amber)
HGR.buffer_to_png(@contents,pallete_mode)
end
|
#to_s ⇒ Object
30
31
32
|
# File 'lib/CPMFile.rb', line 30
def to_s
@contents.gsub(/\x1A*$/,'')
end
|