import yaml


def convert_scalar_node(val):
    """
    Helper to extract and return the appropriately types value of a ScalarNode
    object.

    Arguments:
        val: (yaml.nodes.ScalarNode): object to extract value from

    Returns:
        float, int, string: the actual value
    """
    if not isinstance(val, yaml.nodes.ScalarNode):
        return val
    if val.tag.endswith("int"):
        return int(val.value)
    elif val.tag.endswith("float"):
        return float(val.value)
    else:
        # assume a string
        return val.value