Class: HexFile::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/hex_file/record.rb

Constant Summary collapse

DATA =
'00'
END_OF_FILE =
'01'
EXTENDED_SEGMENT_ADDRESS =
'02'
START_SEGMENT_ADDRESS =
'03'
EXTENDED_LINEAR_ADDRESS =
'04'
START_LINEAR_ADDRESS =
'05'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record_ascii) ⇒ Record



14
15
16
# File 'lib/hex_file/record.rb', line 14

def initialize(record_ascii)
  parse(record_ascii)
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



12
13
14
# File 'lib/hex_file/record.rb', line 12

def address
  @address
end

#byte_countObject (readonly)

Returns the value of attribute byte_count.



12
13
14
# File 'lib/hex_file/record.rb', line 12

def byte_count
  @byte_count
end

#checksumObject (readonly)

Returns the value of attribute checksum.



12
13
14
# File 'lib/hex_file/record.rb', line 12

def checksum
  @checksum
end

#dataObject (readonly)

Returns the value of attribute data.



12
13
14
# File 'lib/hex_file/record.rb', line 12

def data
  @data
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/hex_file/record.rb', line 12

def type
  @type
end

Instance Method Details

#data_sizeObject



18
19
20
# File 'lib/hex_file/record.rb', line 18

def data_size
  @byte_count.to_i(16)
end

#ok?Boolean



22
23
24
# File 'lib/hex_file/record.rb', line 22

def ok?
  @checksum.to_i(16) == calculate_checksum
end