Module: WDD::Utils

Defined in:
lib/wdd-ruby-ext/utils/helpers.rb,
lib/wdd-ruby-ext/utils/spinner.rb,
lib/wdd-ruby-ext/utils/rgb_color.rb,
lib/wdd-ruby-ext/utils/time_gate.rb,
lib/wdd-ruby-ext/utils/miscellany.rb,
lib/wdd-ruby-ext/utils/pretty_xml.rb,
lib/wdd-ruby-ext/utils/simpledebug.rb

Defined Under Namespace

Modules: SimpleDebug Classes: PrettyXml, RGBColor, Spinner, TimeGate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.strip_html(body) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/wdd-ruby-ext/utils/miscellany.rb', line 3

def self.strip_html body
  body = body.to_s
  doc = Nokogiri::HTML::DocumentFragment.parse( CGI.unescapeHTML(body) )
  %w{script style}.each do |element_name|
    while element = doc.at_css(element_name)
      element.remove
    end
  end
  result = strip_tags(doc.to_html)
  result.blank? ? nil : result
end

Instance Method Details

#printvar(val_name, val) ⇒ Object



3
4
5
# File 'lib/wdd-ruby-ext/utils/helpers.rb', line 3

def printvar val_name, val
  puts "#{val_name.to_s}: #{val.inspect}"
end