Class: NRSER::Labs::Globlin
Overview
TODO:
document NRSER::Labs::Globlin class.
Defined Under Namespace
Classes: Matcher
Instance Method Summary collapse
- #find_only!(search_string) ⇒ Object
-
#initialize(split:, ignore: nil) ⇒ Globlin
constructor
Instantiate a new ‘NRSER:Globlin`.
-
#matcher_for(search_string) ⇒ Object
Instance Methods ======================================================================.
Constructor Details
Instance Method Details
#find_only!(search_string) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/nrser/labs/globlin.rb', line 77 def find_only! search_string matcher = matcher_for search_string # Search entries that have the same seg count first found = @seg_count_index[matcher.seg_count].find_all_map { |entry| matcher.match entry } case found.length when 0 # move on.. when 1 return found[0] else raise TooManyError.new found end # Ok, try slice matches for entries with *more* segments only slice_matches = @seg_count_index.keys. select { |count| count > matcher.seg_count }. map { |key| @seg_count_index[key] }. reduce( :+ ). select { |entry| matcher.match_slice entry } end |
#matcher_for(search_string) ⇒ Object
Instance Methods
72 73 74 |
# File 'lib/nrser/labs/globlin.rb', line 72 def matcher_for search_string @split.each end |