lib/mms2r/media.rb
def body
      text_file = default_text

      if RUBY_VERSION < "1.9"
        @body = text_file ? IO.read(text_file.path).strip : ""
        require 'iconv'
        ic = Iconv.new('UTF-8', 'ISO-8859-1')
        @body = ic.iconv(@body)
        @body << ic.iconv(nil)
        ic.close
      else
        @body = text_file ? IO.read(text_file.path, :mode => "rb").strip : ""
        @body = @body.chars.select{|i| i.valid_encoding?}.join
      end

      if @body.blank? &&
         html_file = default_html
        html = Nokogiri::HTML(IO.read(html_file.path))
        @body = (html.xpath("//head/title").map(&:text) + html.xpath("//body/*").map(&:text)).join(" ")
      end
      @body
    end
def body
      text_file = default_text

      if RUBY_VERSION < "1.9"
        @body = text_file ? IO.read(text_file.path).strip : ""
        require 'iconv'
        ic = Iconv.new('UTF-8', 'ISO-8859-1')
        @body = ic.iconv(@body)
        @body << ic.iconv(nil)
        ic.close
      else
        @body = text_file ? IO.read(text_file.path, :mode => "rb").strip : ""
        @body = @body.chars.select{|i| i.valid_encoding?}.join
      end

      if @body.blank? &&
         html_file = default_html
        html = Nokogiri::HTML(IO.read(html_file.path))
        @body = (html.xpath("//head/title").map(&:text) + html.xpath("//body/*").map(&:text)).join(" ")
      end
      @body
    end
Convenience method that returns a string including all the text of the
 default text/plain file found.  If the plain text is blank then it returns
 stripped down version of the title and body of default text/html.  Returns
 empty string if no body text is found.