Function extract_core_build

Source
fn extract_core_build(icons_row: Node<'_>) -> CoreBuildData
Expand description

⚙️ Function: Extracts the core build items from an HTML iconsRow div.

This function processes a div containing the core build items for a champion, typically found in the iconsRow HTML element. It extracts the alt attributes of the item images, cleans them, and returns the first, second, and third items in the build as a CoreBuildData struct.

§Parameters:

  • icons_row: A select::node::Node representing the iconsRow div that contains the item icons for the core build.

§Returns:

  • CoreBuildData: Returns a CoreBuildData struct containing the names of the first, second, and third core build items.

§Example:

This function is typically called to process the core build for a specific champion:

let core_build = extract_core_build(icons_row);
println!("{:?}", core_build);

§Notes:

  • The function collects all img tags within the iconsRow div and extracts the alt attributes, which contain the names of the items.
  • The clean_alt_text function is used to clean the alt text by removing unnecessary characters and formatting it.
  • The function assumes that the images vector contains at least four elements, where the first image is ignored and the second, third, and fourth images represent the core build items.
  • If the iconsRow div does not contain enough images, this could result in an index out of bounds error, so ensure the data is well-formed before calling the function.