Module: Grokdown::Matching
- Defined in:
- lib/grokdown/matching.rb
Constant Summary collapse
- @@knowns =
[]
Class Method Summary collapse
Instance Method Summary collapse
- #matches?(node) ⇒ Boolean (also: #===)
Class Method Details
.=== ⇒ Boolean
21 22 23 |
# File 'lib/grokdown/matching.rb', line 21 def matches?(node) @@knowns.any? { |i| i.matches?(node) } end |
.extended(base) ⇒ Object
9 10 11 |
# File 'lib/grokdown/matching.rb', line 9 def extended(base) @@knowns.push(base) end |
.for(node) ⇒ Object
17 18 19 |
# File 'lib/grokdown/matching.rb', line 17 def for(node) @@knowns.find { |i| i.matches?(node) } end |
.matches?(node) ⇒ Boolean
13 14 15 |
# File 'lib/grokdown/matching.rb', line 13 def matches?(node) @@knowns.any? { |i| i.matches?(node) } end |
Instance Method Details
#matches?(node) ⇒ Boolean Also known as: ===
24 25 26 27 28 |
# File 'lib/grokdown/matching.rb', line 24 def matches?(node) node.is_a?(self) || (node.is_a?(CommonMarker::Node) && matches_node?(node)) rescue NoMethodError => e raise NotImplementedError, "expected #{self} to implement #matches_node?(node) but got: #{e.}" end |