Sha256: cad652cd9b303740dcd0364596b7686142edafeec8526c12edca7bc0e18f592c

Contents?: true

Size: 761 Bytes

Versions: 16

Compression:

Stored size: 761 Bytes

Contents

module Ecoportal
  module API
    class V2
      class Page
        class Component
          class RichTextField < Page::Component
            passthrough :content

            HTML_TAGS_REX = /<("[^"]*"|'[^']*'|[^'">])*>/

            def to_s
              remove_html_tags(content)
            end

            private

            def remove_html_tags(str)
              str = str.gsub(HTML_TAGS_REX, ' ')  if str
              str = str.gsub(/[^[:print:]]/, '') if str
              str = str.gsub(":&nbsp;", ' ')     if str
              str = str.gsub("&#34;", '"')       if str
              str = str.gsub("&amp;", '&')       if str
              str
            end
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ecoportal-api-v2-0.9.3 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.9.2 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.9.1 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.33 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.32 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.31 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.30 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.29 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.28 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.27 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.26 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.25 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.24 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.23 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.22 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-0.8.21 lib/ecoportal/api/v2/page/component/rich_text_field.rb