Class: DOSFile
- Inherits:
-
Object
- Object
- DOSFile
- Defined in:
- lib/DOSFile.rb
Overview
Apple DOS 3.3 file
Direct Known Subclasses
AppleSoftFile, BinaryFile, IntegerBasicFile, SCAsmFile, TextFile
Instance Attribute Summary collapse
-
#contents ⇒ Object
Returns the value of attribute contents.
-
#file_type ⇒ Object
File type as displayed in Apple DOS 3.3 Catalog.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#locked ⇒ Object
Returns the value of attribute locked.
-
#sector_count ⇒ Object
Returns the value of attribute sector_count.
Instance Method Summary collapse
- #hex_dump ⇒ Object
-
#initialize(filename, locked, sector_count, contents, file_type = nil) ⇒ DOSFile
constructor
A new instance of DOSFile.
- #to_s ⇒ Object
Constructor Details
#initialize(filename, locked, sector_count, contents, file_type = nil) ⇒ DOSFile
Returns a new instance of DOSFile.
10 11 12 13 14 15 16 |
# File 'lib/DOSFile.rb', line 10 def initialize(filename,locked,sector_count,contents,file_type=nil) @filename=filename @locked=locked @sector_count=sector_count @file_type= file_type @contents=contents end |
Instance Attribute Details
#contents ⇒ Object
Returns the value of attribute contents.
9 10 11 |
# File 'lib/DOSFile.rb', line 9 def contents @contents end |
#file_type ⇒ Object
File type as displayed in Apple DOS 3.3 Catalog
19 20 21 |
# File 'lib/DOSFile.rb', line 19 def file_type @file_type end |
#filename ⇒ Object
Returns the value of attribute filename.
9 10 11 |
# File 'lib/DOSFile.rb', line 9 def filename @filename end |
#locked ⇒ Object
Returns the value of attribute locked.
9 10 11 |
# File 'lib/DOSFile.rb', line 9 def locked @locked end |
#sector_count ⇒ Object
Returns the value of attribute sector_count.
9 10 11 |
# File 'lib/DOSFile.rb', line 9 def sector_count @sector_count end |
Instance Method Details
#hex_dump ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/DOSFile.rb', line 27 def hex_dump #assumes file is a multiple of 16 bytes, which it always should be s="" (0..(@contents.length/16)-1).each {|line_number| lhs="" rhs="" start_byte=line_number*16 line=@contents[start_byte..start_byte+15] line.each_byte {|byte| lhs+= sprintf("%02X ", byte) rhs+= (byte%128).chr.sub(/[\x00-\x1f]/,'.') } s+=sprintf("%02X\t%s %s\n",start_byte,lhs,rhs) } s end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/DOSFile.rb', line 23 def to_s @contents end |