Sha256: 9e739c085fb480819dad7bc631150ec3b32a97cec8c135f82b5448aae5ce8276

Contents?: true

Size: 960 Bytes

Versions: 94

Compression:

Stored size: 960 Bytes

Contents

module Search
  class Article
    delegate :config, :title, :description, :body, :path, :doc_type, to: :@doc

    def initialize(doc, html)
      @doc  = doc
      @html = html
    end

    def relative_path
      @relative_path ||= "#{config[:base_url_path]}/#{path.relative_path_from(config[:origin])}".gsub('.md', '')
    end

    def product
      @product ||= begin
        product = relative_path.split('/')[1]
        if product == 'messaging'
          "#{relative_path.split('/')[1]} > #{relative_path.split('/')[2]}"
        else
          product
        end
      end
    end

    def to_h
      {
        title: title,
        heading: @html.css('body').children[0].text.strip,
        anchor: @html.css('body').children[0].text.parameterize,
        description: description,
        document_class: doc_type,
        path: relative_path,
        document_path: path,
        body: @html.text,
        product: product,
      }
    end
  end
end

Version data entries

94 entries across 94 versions & 1 rubygems

Version Path
station-0.5.16 lib/nexmo_developer/app/services/search/article.rb
station-0.5.15 lib/nexmo_developer/app/services/search/article.rb
station-0.5.14 lib/nexmo_developer/app/services/search/article.rb
station-0.5.13 lib/nexmo_developer/app/services/search/article.rb
station-0.5.12 lib/nexmo_developer/app/services/search/article.rb
station-0.5.11 lib/nexmo_developer/app/services/search/article.rb
station-0.5.10 lib/nexmo_developer/app/services/search/article.rb
station-0.5.9 lib/nexmo_developer/app/services/search/article.rb
station-0.5.8 lib/nexmo_developer/app/services/search/article.rb
station-0.5.7 lib/nexmo_developer/app/services/search/article.rb
station-0.5.6 lib/nexmo_developer/app/services/search/article.rb
station-0.5.5 lib/nexmo_developer/app/services/search/article.rb
station-0.5.4 lib/nexmo_developer/app/services/search/article.rb
station-0.5.3 lib/nexmo_developer/app/services/search/article.rb
station-0.5.2 lib/nexmo_developer/app/services/search/article.rb
station-0.5.1 lib/nexmo_developer/app/services/search/article.rb
station-0.5.0 lib/nexmo_developer/app/services/search/article.rb
station-0.4.9 lib/nexmo_developer/app/services/search/article.rb
station-0.4.8 lib/nexmo_developer/app/services/search/article.rb
station-0.4.7 lib/nexmo_developer/app/services/search/article.rb