Class: Bemer::Predicate
- Inherits:
-
Object
- Object
- Bemer::Predicate
- Defined in:
- lib/bemer/predicate.rb
Instance Method Summary collapse
-
#initialize(**options) ⇒ Predicate
constructor
A new instance of Predicate.
- #match?(node) ⇒ Boolean
- #name_match?(name) ⇒ Boolean
- #wildcard? ⇒ Boolean
Constructor Details
#initialize(**options) ⇒ Predicate
Returns a new instance of Predicate.
5 6 7 8 9 10 11 12 13 |
# File 'lib/bemer/predicate.rb', line 5 def initialize(**) @block = [:block] @condition = [:condition].nil? ? true : [:condition] @element = [:elem] @mask = build_mask([:block], [:elem]) @mixins = Mixes.new([:mix]) @modifiers = ModifierList.new(:block, :elem, [:mods]) @wildcard = nil end |
Instance Method Details
#match?(node) ⇒ Boolean
15 16 17 |
# File 'lib/bemer/predicate.rb', line 15 def match?(node) condition?(node) && mix?(node.mix) && mods?(node.mods) end |
#name_match?(name) ⇒ Boolean
19 20 21 |
# File 'lib/bemer/predicate.rb', line 19 def name_match?(name) Bemer.can_use_new_matcher? ? mask.match?(name) : mask =~ name end |
#wildcard? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/bemer/predicate.rb', line 23 def wildcard? return wildcard unless wildcard.nil? @wildcard = name.include?('*') end |