Updated finder in subtlext
Finer grained control in finders!
Let us start from the beginning before I go on about the recent changes in r2921.¶
There are finders inside of subtlext to find subtle objects from the Ruby side. They are available for most of the subtlext objects (excluded are just Color, Geometry and Icon) and can be used either with the #find method or when you are lazy like me with #[]. They support multiple argument types like fixnum, string and symbols and they can only return one match.
Subtlext::Client['urxvt']
=> #<Subtlext::Client:xxx>
Q: What happens, when there is more than one client with that name, which one is returned and how can I access both?
A: Nothing happens, the first found client is returned and there is no way to access the other match from the finder.
Q: What happens, when I have multiple urxvts with names like urxvt1, urxvt2?
A: Nothing happens, the first found client is still returned, the input string 'urxvt' can match partially.
Q: How can I match case-sensitive?
A: There is currently no way, sorry.
Q: How can find e.g. the gravity center, when I have center, center33 and center66?
A: Use the end of line symbol:
Subtlext::Client['center$']
r2921 for the help!¶
The updates finders work a bit different than before:
- Finders can return multiple matches as array or a single object
- Symbols require exact matches and are case-sensitive
Here is a small comparison to see what the different arguments really do:
Argument | Code | Result |
---|---|---|
13 | |
#<Subtlext::Gravity:xxx> |
center | |
[ #<Subtlext::Gravity:xxx>, <Subtlext::Gravity:xxx>, #<Subtlext::Gravity:xxx> ] |
center$ | |
#<Subtlext::Gravity:xxx> |
:center | |
#<Subtlext::Gravity:xxx> |
Comments