wieden-kennedy/salad — pull request #41 by medwards (2012-12-20 13:34:01+00:00)
Title: _get_element signature is simpler

Its a big blob but the change is pretty simple:

I didn't like all the 'first, last' things kicking around so I made `pick_to_index` which can parse the `( first| last)?` regex group into an array index. `pick_to_index` is future-proofed to support '1st, 2nd, 3rd, 4th' and so on, but I didn't put it in yet (I'm bad at regex).

Some things I don't like:
* `pick_to_index` returns 0 when it receives `None` (although now that its encapsulated in `_get_element` maybe I can move the logic there)
* I want to just pass a raw index to `_get_element` but it gets really gross because that means every step generator has a call to `pick_to_index` which seemed like too much burden so I just pushed it down
* `_convert_to_css` hasn't been converted to this, partly because there is no `second-child` selector nor did it ever default to `first` like `_get_element` but also because I'm worried that the first and last selectors might be be incorrectly implemented here (I could only find references to `first-child` and `last-child` online for example)

Anyways, I like the step method definitions and `_get_element`'s definition a lot more now. Let me know what you think!