Chapter 09/circuit-oneops-1-master/components/cookbooks/spark-v1/recipes/spark_helper.rb
def instanceid_from_name(ciName)
  if ciName == nil || ciName.empty?
    # There was not a name specified.  Just return nothing.
    return ''
  end

  # The instance ID is the last component of the CI name:
  #
  # basename-cloudid-instance
  #
  # Split on the '-' character and take the last component.
  # Don't count from the front since the ciName may contain
  # hyphens.
  #
  nameComponents = ciName.split('-',-1)

  instanceid = nameComponents[nameComponents.length - 1]

  return instanceid
end
# Parse the ciName to extract the instance number from it
#
# INPUT:
# ciName: The CI name to parse
#
# RETURNS:
# A string containing the numeric instance ID, or '' if no
# name was specified
#
Parse the ciName to extract the instance number from it
INPUT:
ciName: The CI name to parse

A string containing the numeric instance ID, or '' if no
name was specified
Parse the ciName to extract the instance number from it INPUT : ciName : The CI name to parse A string containing the numeric instance ID or ' ' if no name was specified
def instanceid_from_name(ciName)
  if ciName == nil || ciName.empty?
    return ''
  end
   basename-cloudid-instance
   Split on the '-' character and take the last component.
   Don't count from the front since the ciName may contain
   hyphens.
  nameComponents = ciName.split('-',-1)
  instanceid = nameComponents[nameComponents.length - 1]
  return instanceid
end
def instanceid_from_name ( ciName ) if ciName == nil || ciName . empty? return '' end nameComponents = ciName . split ( '-' , - 1 ) instanceid = nameComponents [ nameComponents . length - 1 ] return instanceid end
Parse the ciName to extract the instance number from it
INPUT:
ciName: The CI name to parse
Parse the ciName to extract the instance number from it INPUT : ciName : The CI name to parse
# There was not a name specified.  Just return nothing. # The instance ID is the last component of the CI name: # # basename-cloudid-instance # # Split on the '-' character and take the last component. # Don't count from the front since the ciName may contain # hyphens. #
ciName