# `IntelHex.Block`
[🔗](https://github.com/fhunleth/intel_hex/blob/v0.2.1/lib/intel_hex/block.ex#L1)

A block is a contiguous set of bytes at an address

If you're working with `IntelHex` only, then you don't need to worry about
this module. However, handling blocks directly can enable more complex
manipulations of the data stored in `.hex` files.

Generally programs pass around lists of `Block`s. Functions in this library
expect these lists to conform to the following rules:

1. Sorted by address from lowest address to highest
2. No overlaps between blocks
3. A gap of one or more bytes separates each block

Calling `normalize/1` will ensure that `Block` lists follow these rules.

# `t`

```elixir
@type t() :: %IntelHex.Block{address: non_neg_integer(), data: binary()}
```

# `blocks_to_records`

```elixir
@spec blocks_to_records(
  [t()],
  keyword()
) :: [IntelHex.Record.t()]
```

Turn a list of memory blocks back to records

Only linear addressing is supported.

Options:
* `:block_size` - the max data bytes per record. (defaults to 16)

# `new`

```elixir
@spec new(non_neg_integer(), binary()) :: t()
```

Create a new block

# `normalize`

```elixir
@spec normalize([t()]) :: [t()]
```

Normalize a list of blocks

This makes sure that they're sorted, non-overlapping and blocks that are next
to each other get merged. This is normally done automatically, but if you're
manually creating block lists and unsure whether there are overlaps or
adjacent blocks, then it's recommended to run this.

# `records_to_blocks`

```elixir
@spec records_to_blocks([IntelHex.Record.t()]) :: [t()]
```

Convert a list of records to memory blocks

The returned list of blocks is sorted, merged, and any overlaps resolved.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
