Class: Querly::Pattern::Kind::Conditional
- Includes:
- Negatable
- Defined in:
- lib/querly/pattern/kind.rb
Instance Attribute Summary
Attributes included from Negatable
Attributes inherited from Base
Instance Method Summary collapse
Methods included from Negatable
Methods inherited from Base
Instance Method Details
#conditional?(pair) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/querly/pattern/kind.rb', line 34 def conditional?(pair) node = pair.node parent = pair.parent&.node case parent&.type when :if node.equal? parent.children.first when :while node.equal? parent.children.first when :and node.equal? parent.children.first when :or node.equal? parent.children.first when :csend node.equal? parent.children.first else false end end |
#test_kind(pair) ⇒ Object
30 31 32 |
# File 'lib/querly/pattern/kind.rb', line 30 def test_kind(pair) !negated == !!conditional?(pair) end |