Module: LCBO::CrawlKit::CaptionHelper

Defined in:
lib/lcbo/crawlkit/caption_helper.rb

Class Method Summary collapse

Class Method Details

.[](value) ⇒ Object



5
6
7
8
9
# File 'lib/lcbo/crawlkit/caption_helper.rb', line 5

def self.[](value)
  return if '' == value.to_s.strip
  caption = normalize_whitespace(strip_html(value))
  '' == caption ? nil : caption
end

.normalize_whitespace(value) ⇒ Object



11
12
13
# File 'lib/lcbo/crawlkit/caption_helper.rb', line 11

def self.normalize_whitespace(value)
  value.gsub(/\s+/, ' ').strip
end

.strip_html(value) ⇒ Object



15
16
17
# File 'lib/lcbo/crawlkit/caption_helper.rb', line 15

def self.strip_html(value)
  value.gsub(/\<.+?\>/, '')
end