Module: IOSParser::IOS::Queryable
Defined Under Namespace
Modules: Matcher, MatcherReader
Instance Method Summary
collapse
Instance Method Details
#_find(expr, &blk) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/ios_parser/ios/queryable.rb', line 29
def _find(expr, &blk)
_find_all(expr) do |command|
yield(command) if blk
return command
end
nil
end
|
#_find_all(expr, &blk) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/ios_parser/ios/queryable.rb', line 12
def _find_all(expr, &blk)
[].tap do |ret|
commands.each do |command|
if match_expr(expr, command)
ret << command
yield(command) if blk
end
ret.push(*command._find_all(expr, &blk))
end
end
end
|
#find(expr, &blk) ⇒ Object
#find_all(expr, &blk) ⇒ Object
#match_expr(expr, command) ⇒ Object
25
26
27
|
# File 'lib/ios_parser/ios/queryable.rb', line 25
def match_expr(expr, command)
expr.each_pair.all? { |pred, arg| Matcher.send(pred, arg, command) }
end
|