Module: OrigenMemoryImage
- Defined in:
- lib/origen_memory_image.rb,
lib/origen_memory_image/hex.rb,
lib/origen_memory_image/base.rb,
lib/origen_memory_image/binary.rb,
lib/origen_memory_image/s_record.rb,
lib/origen_memory_image/intel_hex.rb
Defined Under Namespace
Classes: Base, Binary, Hex, IntelHex, SRecord
Class Method Summary collapse
-
.find_type(file, options = {}) ⇒ Object
Returns the class of the image manager for the given file.
- .new(file, options = {}) ⇒ Object
Class Method Details
.find_type(file, options = {}) ⇒ Object
Returns the class of the image manager for the given file
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/origen_memory_image.rb', line 19 def self.find_type(file, = {}) # Read first 10 lines if [:source] == String snippet = file.split("\n") else snippet = File.foreach(file.to_s).first(10) end case # Always do the binary first since the others won't be able to process # a binary snippet when [:type] == :binary || ([:source] != String && Binary.match?(file)) Binary when [:source] == String && Binary.match?(snippet, true) Binary when [:type] == :srecord || SRecord.match?(snippet) SRecord when [:type] == :intel_hex || IntelHex.match?(snippet) IntelHex when [:type] == :hex || Hex.match?(snippet) Hex else fail "Unknown format for image file: #{file}" end end |
.new(file, options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/origen_memory_image.rb', line 11 def self.new(file, = {}) unless [:source] == String file = Origen.file_handler.clean_path_to(file) end find_type(file, ).new(file, ) end |