Skip to content

Instantly share code, notes, and snippets.

@wbreeze
Created April 21, 2014 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wbreeze/11156757 to your computer and use it in GitHub Desktop.
Save wbreeze/11156757 to your computer and use it in GitHub Desktop.
Business logic for determining IAC flight K values
def k_values_for(jCat, jFlt, jPilot)
if (jCat == 1) # primary has no free
jFlt = 1
end
if (jCat == 2) # sportsman has no unknown
jFlt = 2 if 2 < jFlt
end
case jFlt
when 2 # free
nodes = @document.find("/ContestResults/Pilots/Category[@CategoryID=#{jCat}]/Pilot[@PilotID=#{jPilot}]/FreestyleKs")
if (nodes.length == 0)
nodes = @document.find("/ContestResults/KnownKFactors/Category[@CategoryID=#{jCat}]")
end
when 3 # unknown
nodes = @document.find("/ContestResults/UnKnownKFactors/One/Category[@CategoryID=#{jCat}]")
when 4 # unknown II
nodes = @document.find("/ContestResults/UnKnownKFactors/Two/Category[@CategoryID=#{jCat}]")
else # known
nodes = @document.find("/ContestResults/KnownKFactors/Category[@CategoryID=#{jCat}]")
end
nodes && nodes.first ? nodes.first.inner_xml : ''
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment