t @make_now_just / g @makenowjust ‣ Ph.D student a t N a tion a l Institute of Inform a tics / SOKENDAI ‣ Work p a rt-time a t STORES, Inc. ‣ Ruby committer (regex engine, memoiz a tion) 2
a node m a tching from - selector: a CSS selector string ‣ It c a lls a block with a m a tched node. ‣ Other APIs: - select_all, select, is REXML::CSSSelector.each_select Usage 8
a v a lue is expected. ‣ This v a lue is repl a ced by substitutions[name] on run-time. REXML::CSSSelector.select_all( scope, 'div#main input[class=$user_value]', substitutions: { user_value: } ) A safe way to handle user values.
oper a tions a re a bstr a cted by a d a pters. - element?, get_parent_node, get_attribute, ... ‣ Def a ult: REXMLAdapter ‣ By implementing a n a d a pter for our tree, we c a n get CSS selector m a tching for this. ‣ → PrismAdapter Generic usage of CSS selector.
child child v a lue=2 v a lue=1 v a lue=3 root > p a rent > child[v a lue=2] def each_select(scope, selector) each_recursive(scope) do |node| yield node if is(node, selector) end end
child child v a lue=2 v a lue=1 v a lue=3 root > p a rent > child[v a lue=2] ᶃ ᶄ ᶅ ᶆ ᶇ ᶈ def each_select(scope, selector) each_recursive(scope) do |node| yield node if is(node, selector) end end
child child v a lue=2 v a lue=1 v a lue=3 root > p a rent > child[v a lue=2] def each_select(scope, selector) each_recursive(scope) do |node| yield node if is(node, selector) end end