Class: Querly::Pattern::Kind::Discarded

Inherits:
Base
  • Object
show all
Includes:
Negatable
Defined in:
lib/querly/pattern/kind.rb

Instance Attribute Summary

Attributes included from Negatable

#negated

Attributes inherited from Base

#expr

Instance Method Summary collapse

Methods included from Negatable

#initialize

Methods inherited from Base

#initialize

Instance Method Details

#discarded?(pair) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/querly/pattern/kind.rb', line 60

def discarded?(pair)
  node = pair.node
  parent = pair.parent&.node

  case parent&.type
  when :begin
    if node.equal? parent.children.last
      discarded? pair.parent
    else
      true
    end
  else
    false
  end
end

#test_kind(pair) ⇒ Object



56
57
58
# File 'lib/querly/pattern/kind.rb', line 56

def test_kind(pair)
  !negated == !!discarded?(pair)
end