views:

55

answers:

1

I have product that the product serial number equals product series, chip, model, manufacture, software, etc. Each of these has its own table with all the information I need in it.

Each product serial number is 8 characters long. i.e. 1B43A672, 18GH8843. The second value determines how to map the serial number to which table. i.e. If the second value is B then that is a Intel Atom 1.6 and its mapped like this: Position_1 == @series; Position_2 == @processor; Position_3 == @model

But if second value is 8 then its mapped like this: Position_1 == @manufacture;Position_2 == @processor; Position_3 == @software

If I have a user input text field (like a search), how can I get it to extract each value in each position so I can call a function that performs the mapping?

A: 

How about splitting the user input string?

>> request_string = "1B43A672"
>> second_value = request_string.split("")[1]
>> p second_value
=> "B"
# process with lookup ...

Do the specific lookup via case for example:

case second_value
  when "B"
    ...
  when "8"
    ...
end
The MYYN