Class: Msp430Bsl::DataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/msp430_bsl/data_file.rb

Direct Known Subclasses

HexFile, RawDataFile

Constant Summary collapse

LINE_DATA_SIZE =
Configs::PURE_DATA_MAX_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDataFile

Returns a new instance of DataFile.



8
9
10
# File 'lib/msp430_bsl/data_file.rb', line 8

def initialize
  @lines = []
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



6
7
8
# File 'lib/msp430_bsl/data_file.rb', line 6

def lines
  @lines
end

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/msp430_bsl/data_file.rb', line 6

def path
  @path
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



6
7
8
# File 'lib/msp430_bsl/data_file.rb', line 6

def raw_data
  @raw_data
end

Instance Method Details

#<<(line) ⇒ Object



20
21
22
# File 'lib/msp430_bsl/data_file.rb', line 20

def <<(line)
  @lines << line
end

#add_new_lines_from(data, starting_addr) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/msp430_bsl/data_file.rb', line 12

def add_new_lines_from(data, starting_addr)
  curr_addr = starting_addr
  data.each_slice(line_data_size) do |slice|
    @lines << new_line_from(slice, curr_addr)
    curr_addr += line_data_size
  end
end

#line_data_sizeObject



24
25
26
# File 'lib/msp430_bsl/data_file.rb', line 24

def line_data_size
  self.class::LINE_DATA_SIZE
end

#new_line_from(data, addr, type: :data) ⇒ Object

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/msp430_bsl/data_file.rb', line 28

def new_line_from(data, addr, type: :data)
  raise NotImplementedError, 'You must implement this method in a subclass'
end