Class: Msp430Bsl::HexFile
- Inherits:
-
Object
- Object
- Msp430Bsl::HexFile
- Defined in:
- lib/msp430_bsl/hex_file.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#raw_data ⇒ Object
readonly
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #data_lines_grouped_by_contiguous_addr ⇒ Object
-
#initialize(path) ⇒ HexFile
constructor
A new instance of HexFile.
- #lines ⇒ Object
Constructor Details
#initialize(path) ⇒ HexFile
Returns a new instance of HexFile.
6 7 8 9 |
# File 'lib/msp430_bsl/hex_file.rb', line 6 def initialize(path) @path = File. path @raw_data = File.read path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/msp430_bsl/hex_file.rb', line 4 def path @path end |
#raw_data ⇒ Object (readonly)
Returns the value of attribute raw_data.
4 5 6 |
# File 'lib/msp430_bsl/hex_file.rb', line 4 def raw_data @raw_data end |
Instance Method Details
#data_lines_grouped_by_contiguous_addr ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/msp430_bsl/hex_file.rb', line 19 def data_lines_grouped_by_contiguous_addr return @grouped_lines if @grouped_lines @grouped_lines = [] curr_group = nil curr_addr = nil prev_line = nil lines.each do |line| next unless line.is_of_type? :data if curr_addr.nil? # We just started a new group curr_addr = line.addr curr_group = [line] elsif line.has_addr_contiguous_to? prev_line # We already have a current group curr_group << line curr_addr = line.addr else @grouped_lines << curr_group curr_addr = nil redo end prev_line = line end @grouped_lines << curr_group if curr_group.any? @grouped_lines end |