ecto_playlist v0.0.1 EctoPlaylist.ListItem View Source
Implements conveniences to change the items order of a list.
Link to this section Summary
Functions
Check if list item id is the first element in the ordering.
Return the list item id which is one rank higher in the ordering.
Return the list of ids above the list item id.
Check if list item id is in the ordering.
Insert an list item id in the given index of an order_list
Check if list item id is the last element in the ordering.
Return the list item id which is one rank lower in the ordering.
Return the list of ids below the list item id.
Move the list item id one rank higher in the ordering.
Move the list item id one rank lower in the ordering.
Move the list item id at the last position in the ordering.
Move the list item id at the first position in the ordering.
Check if list item id is in the ordering.
Remove the list item id in the ordering.
Link to this section Functions
first?(order_list, list_item) View Source
Check if list item id is the first element in the ordering.
iex> EctoPlaylist.ListItem.first?([1, 2, 3, 4], 1)
true
iex> EctoPlaylist.ListItem.first?([1, 2, 3, 4], 3)
false
iex> EctoPlaylist.ListItem.first?([1, 2, 3, 4], 5)
false
higher_item(order_list, list_item) View Source
Return the list item id which is one rank higher in the ordering.
iex> EctoPlaylist.ListItem.higher_item([1, 7, 3, 4], 3)
7
iex> EctoPlaylist.ListItem.higher_item([1, 2, 3, 4], 1)
nil
iex> EctoPlaylist.ListItem.higher_item([1, 2, 3, 4], 5)
nil
higher_items(order_list, list_item) View Source
Return the list of ids above the list item id.
iex> EctoPlaylist.ListItem.higher_items([1, 2, 3, 4], 3)
[1, 2]
iex> EctoPlaylist.ListItem.higher_items([1, 2, 3, 4], 4)
[1, 2, 3]
iex> EctoPlaylist.ListItem.higher_items([1, 2, 3, 4], 1)
[]
iex> EctoPlaylist.ListItem.higher_items([1, 2, 3, 4], 5)
nil
in_list?(order_list, list_item) View Source
Check if list item id is in the ordering.
iex> EctoPlaylist.ListItem.in_list?([1, 2, 3, 4], 3)
true
iex> EctoPlaylist.ListItem.in_list?([1, 2, 3, 4], 5)
false
insert_at(order_list, list_item, index) View Source
Insert an list item id in the given index of an order_list
iex> EctoPlaylist.ListItem.insert_at([1, 2, 3, 4], 9, 2)
[1, 9, 2, 3, 4]
iex> EctoPlaylist.ListItem.insert_at([1, 2, 3], 9, 10)
[1, 2, 3, 9]
iex> EctoPlaylist.ListItem.insert_at([1, 2, 9, 3], 9, 2)
[1, 9, 2, 3]
iex> EctoPlaylist.ListItem.insert_at([1, 2, 9, 3], 9, 10)
[1, 2, 3, 9]
iex> EctoPlaylist.ListItem.insert_at([1, 2, 9, 3], 9, nil)
[1, 2, 9, 3]
last?(order_list, list_item) View Source
Check if list item id is the last element in the ordering.
iex> EctoPlaylist.ListItem.last?([1, 2, 3, 4], 4)
true
iex> EctoPlaylist.ListItem.last?([1, 2, 3, 4], 2)
false
iex> EctoPlaylist.ListItem.last?([1, 2, 3, 4], 5)
false
lower_item(order_list, list_item) View Source
Return the list item id which is one rank lower in the ordering.
iex> EctoPlaylist.ListItem.lower_item([1, 2, 3, 7], 3)
7
iex> EctoPlaylist.ListItem.lower_item([1, 2, 3, 4], 4)
nil
iex> EctoPlaylist.ListItem.lower_item([1, 2, 3, 4], 5)
nil
lower_items(order_list, list_item) View Source
Return the list of ids below the list item id.
iex> EctoPlaylist.ListItem.lower_items([1, 2, 3, 4], 2)
[3, 4]
iex> EctoPlaylist.ListItem.lower_items([1, 2, 3, 4], 1)
[2, 3, 4]
iex> EctoPlaylist.ListItem.lower_items([1, 2, 3, 4], 4)
[]
iex> EctoPlaylist.ListItem.lower_items([1, 2, 3, 4], 5)
nil
move_higher(order_list, list_item) View Source
Move the list item id one rank higher in the ordering.
iex> EctoPlaylist.ListItem.move_higher([1, 2, 3, 4], 3)
[1, 3, 2, 4]
iex> EctoPlaylist.ListItem.move_higher([1, 2, 3, 4], 1)
[1, 2, 3, 4]
iex> EctoPlaylist.ListItem.move_higher([1, 2, 3, 4], 5)
[1, 2, 3, 4]
move_lower(order_list, list_item) View Source
Move the list item id one rank lower in the ordering.
iex> EctoPlaylist.ListItem.move_lower([1, 2, 3, 4], 3)
[1, 2, 4, 3]
iex> EctoPlaylist.ListItem.move_lower([1, 2, 3, 4], 1)
[2, 1, 3, 4]
iex> EctoPlaylist.ListItem.move_lower([1, 2, 3, 4], 4)
[1, 2, 3, 4]
iex> EctoPlaylist.ListItem.move_lower([1, 2, 3, 4], 5)
[1, 2, 3, 4]
move_to_bottom(order_list, list_item) View Source
Move the list item id at the last position in the ordering.
iex> EctoPlaylist.ListItem.move_to_bottom([1, 2, 3, 4], 3)
[1, 2, 4, 3]
iex> EctoPlaylist.ListItem.move_to_bottom([1, 2, 3, 4], 1)
[2, 3, 4, 1]
iex> EctoPlaylist.ListItem.move_to_bottom([1, 2, 3, 4], 4)
[1, 2, 3, 4]
iex> EctoPlaylist.ListItem.move_to_bottom([1, 2, 3, 4], 5)
[1, 2, 3, 4, 5]
move_to_top(order_list, list_item) View Source
Move the list item id at the first position in the ordering.
iex> EctoPlaylist.ListItem.move_to_top([1, 2, 3, 4], 3)
[3, 1, 2, 4]
iex> EctoPlaylist.ListItem.move_to_top([1, 2, 3, 4], 1)
[1, 2, 3, 4]
iex> EctoPlaylist.ListItem.move_to_top([1, 2, 3, 4], 5)
[5, 1, 2, 3, 4]
not_in_list?(order_list, list_item) View Source
Check if list item id is in the ordering.
iex> EctoPlaylist.ListItem.not_in_list?([1, 2, 3, 4], 5)
true
iex> EctoPlaylist.ListItem.not_in_list?([1, 2, 3, 4], 3)
false
remove_from_list(order_list, list_item) View Source
Remove the list item id in the ordering.
iex> EctoPlaylist.ListItem.remove_from_list([1, 2, 3, 4], 3)
[1, 2, 4]
iex> EctoPlaylist.ListItem.remove_from_list([1, 2, 3, 4], 1)
[2, 3, 4]
iex> EctoPlaylist.ListItem.remove_from_list([1, 2, 3, 4], 5)
[1, 2, 3, 4]