# `LeXtract.CharInterval`
[🔗](https://github.com/YgorCastor/lextract.git/blob/main/lib/lextract/char_interval.ex#L1)

Represents a character position interval in text.

## Fields

* `:start_pos` - Starting character position (0-based, inclusive)
* `:end_pos` - Ending character position (0-based, exclusive)

## Examples

    iex> interval = %LeXtract.CharInterval{start_pos: 0, end_pos: 5}
    iex> LeXtract.CharInterval.length(interval)
    5

# `t`

```elixir
@type t() :: %LeXtract.CharInterval{
  end_pos: non_neg_integer(),
  start_pos: non_neg_integer()
}
```

# `extract`

```elixir
@spec extract(String.t(), t()) :: String.t()
```

Extracts text from a string using this interval.

## Examples

    iex> interval = LeXtract.CharInterval.new(0, 5)
    iex> LeXtract.CharInterval.extract("Hello, world!", interval)
    "Hello"

# `length`

```elixir
@spec length(t()) :: non_neg_integer()
```

Returns the length of the interval.

## Examples

    iex> interval = LeXtract.CharInterval.new(10, 20)
    iex> LeXtract.CharInterval.length(interval)
    10

# `new`

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

Creates a new character interval.

## Examples

    iex> LeXtract.CharInterval.new(0, 10)
    %LeXtract.CharInterval{start_pos: 0, end_pos: 10}

# `overlaps?`

```elixir
@spec overlaps?(t(), t()) :: boolean()
```

Checks if two intervals overlap.

## Examples

    iex> i1 = LeXtract.CharInterval.new(0, 5)
    iex> i2 = LeXtract.CharInterval.new(3, 8)
    iex> LeXtract.CharInterval.overlaps?(i1, i2)
    true

    iex> i1 = LeXtract.CharInterval.new(0, 5)
    iex> i2 = LeXtract.CharInterval.new(5, 10)
    iex> LeXtract.CharInterval.overlaps?(i1, i2)
    false

---

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