Sha256: 0065f19d970d910ccb98d8694e18808802c2a87fe3af6ca34c779adb1ea0f8dc

Contents?: true

Size: 842 Bytes

Versions: 26

Compression:

Stored size: 842 Bytes

Contents

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

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

            def empty?
              to_s.to_s.strip.empty?
            end

            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

26 entries across 26 versions & 1 rubygems

Version Path
ecoportal-api-v2-2.0.12 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.11 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.10 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.9 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.8 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.7 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.6 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.5 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.4 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.3 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.2 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.1 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-2.0.0 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.8 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.7 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.6 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.5 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.4 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.3 lib/ecoportal/api/v2/page/component/rich_text_field.rb
ecoportal-api-v2-1.1.2 lib/ecoportal/api/v2/page/component/rich_text_field.rb