Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/undertexter/array.rb
Overview
str =~ /(sd2ed2)/i && !(str =~ /#$1/i)
Instance Method Summary collapse
Instance Method Details
#based_on(string, args = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/undertexter/array.rb', line 6 def based_on(string, args = {}) result = self.any? ? self.map do|s| [Levenshtein.distance(s.title, string, args[:limit] || 0.4), s] end.reject do |value| value.first.nil? end.sort_by do |value| value.first end.map(&:last).first : nil return if result.nil? # If the string contains a release date, then the results should do it to if result.title =~ /(s\d{2}e\d{2})/i return unless string.match(/#{$1}/i) end # If the {string} contains a year, then the found movie should return one to if result.title =~ /((19|20)\d{2})/ return unless string.match(/#{$1}/) end # Yes i know, return isn't needed return result end |