Module: Reckless::Normalizer
- Included in:
- ResultsParser
- Defined in:
- lib/reckless/normalizer.rb
Instance Method Summary collapse
-
#normalize_artist(text) ⇒ Object
Transform artist name to normal representation Example: Beck, Jeff => Jeff Beck.
-
#normalize_text(text) ⇒ Object
Transform text from all caps to normal capitalized words Example: SOME GREAT BAND => Some Great Band.
Instance Method Details
#normalize_artist(text) ⇒ Object
Transform artist name to normal representation Example: Beck, Jeff => Jeff Beck
15 16 17 18 19 20 21 22 23 |
# File 'lib/reckless/normalizer.rb', line 15 def normalize_artist(text) if text =~ /[\d]+,[\d]+/ text else text.gsub(/(([\w]+),\s?([\w]+))/) do |m| m = "#{$3} #{$2}" end end end |
#normalize_text(text) ⇒ Object
Transform text from all caps to normal capitalized words Example: SOME GREAT BAND => Some Great Band
7 8 9 |
# File 'lib/reckless/normalizer.rb', line 7 def normalize_text(text) text.downcase.split.map(&:capitalize).join(" ") end |