Class: PascalFile
Overview
Pascal file
Constant Summary collapse
- PASCAL_FILE_TYPES =
[:untyped,:xdsk,:code,:text,:info,:data,:graf,:foto,:securedir]
Constants inherited from DSKFile
Instance Attribute Summary collapse
-
#file_type ⇒ Object
Returns the value of attribute file_type.
Attributes inherited from DSKFile
Instance Method Summary collapse
- #can_be_picture? ⇒ Boolean
- #file_extension ⇒ Object
-
#initialize(filename, contents, file_type) ⇒ PascalFile
constructor
A new instance of PascalFile.
- #to_png(pallete_mode = :amber) ⇒ Object
- #to_s ⇒ Object
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_type ⇒ Object
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
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_extension ⇒ Object
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_s ⇒ Object
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 |