View Source PieceTable.Change (piece_table v0.1.4)
A struct to hold changes in the PieceTable
usage
Usage
iex> PieceTable.Change.new!(:ins, "test", 3, "bob")
%PieceTable.Change{change: :ins, position: 3, text: "test", blame: "bob"}
Link to this section Summary
Functions
Inverts the operation of a PieceTable.Change struct.
Inverts the operation of a PieceTable.Change struct.
Creates a new PieceTable.Change struct. This is intended the only method to build it.
Creates a new PieceTable.Change struct. This is intended the only method to build it.
Link to this section Types
Link to this section Functions
Inverts the operation of a PieceTable.Change struct.
parameters
Parameters
chg
(PieceTable.Change.t()): The change to invert
returns
Returns
{:ok, %PieceTable.Change{}}
{:error, :wrong_argument}
examples
Examples
iex> PieceTable.Change.invert(%PieceTable.Change{change: :ins, text: "random", position: 5, blame: nil})
{:ok, %PieceTable.Change{change: :del, text: "random", position: 5, blame: nil}}
Inverts the operation of a PieceTable.Change struct.
parameters
Parameters
chg
(PieceTable.Change.t()): The change to invert
returns
Returns
%PieceTable.Change{}
examples
Examples
iex> PieceTable.Change.invert(%PieceTable.Change{change: :ins, text: "random", position: 5, blame: nil})
{:ok, %PieceTable.Change{change: :del, text: "random", position: 5, blame: nil}}
Creates a new PieceTable.Change struct. This is intended the only method to build it.
parameters
Parameters
change
(atom()): The operation it represents [:ins | :del]text
(String.t()): The text to editposition
(integer()): The position at which the edit occursblame
(any()): An optional ID to track who created the change
returns
Returns
{:ok, %PieceTable.Change{}}
{:error, :wrong_arguments}
examples
Examples
iex> PieceTable.Change.new(:ins, "test", 4, nil)
{:ok, %PieceTable.Change{change: :ins, text: "test", position: 4, blame: nil}}
Creates a new PieceTable.Change struct. This is intended the only method to build it.
parameters
Parameters
change
(atom()): The operation it represents [:ins | :del]text
(String.t()): The text to editposition
(integer()): The position at which the edit occursblame
(any()): An optional ID to track who created the change
returns
Returns
%PieceTable.Change{}
examples
Examples
iex> PieceTable.Change.new!(:ins, "test", 4, nil)
%PieceTable.Change{change: :ins, text: "test", position: 4, blame: nil}