Sha256: b2573f75f9553f78511215597d2a7311152f3f9df580ec225659d8424661293f

Contents?: true

Size: 745 Bytes

Versions: 94

Compression:

Stored size: 745 Bytes

Contents

module Search
  class Document
    attr_reader :doc_type, :config, :path

    def initialize(doc_type, config, path)
      @doc_type = doc_type
      @config   = config
      @path     = Pathname.new(path)
    end

    def articles
      @articles ||= Nokogiri::HTML(body).split_html.map do |section_html|
        Search::Article.new(self, section_html)
      end
    end

    def document
      @document ||= File.read(@path)
    end

    def frontmatter
      @frontmatter ||= YAML.safe_load(document)
    end

    def title
      @title ||= frontmatter['title']
    end

    def description
      @description ||= frontmatter['description']
    end

    def body
      @body ||= Nexmo::Markdown::Renderer.new.call(document)
    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/document.rb
station-0.5.15 lib/nexmo_developer/app/services/search/document.rb
station-0.5.14 lib/nexmo_developer/app/services/search/document.rb
station-0.5.13 lib/nexmo_developer/app/services/search/document.rb
station-0.5.12 lib/nexmo_developer/app/services/search/document.rb
station-0.5.11 lib/nexmo_developer/app/services/search/document.rb
station-0.5.10 lib/nexmo_developer/app/services/search/document.rb
station-0.5.9 lib/nexmo_developer/app/services/search/document.rb
station-0.5.8 lib/nexmo_developer/app/services/search/document.rb
station-0.5.7 lib/nexmo_developer/app/services/search/document.rb
station-0.5.6 lib/nexmo_developer/app/services/search/document.rb
station-0.5.5 lib/nexmo_developer/app/services/search/document.rb
station-0.5.4 lib/nexmo_developer/app/services/search/document.rb
station-0.5.3 lib/nexmo_developer/app/services/search/document.rb
station-0.5.2 lib/nexmo_developer/app/services/search/document.rb
station-0.5.1 lib/nexmo_developer/app/services/search/document.rb
station-0.5.0 lib/nexmo_developer/app/services/search/document.rb
station-0.4.9 lib/nexmo_developer/app/services/search/document.rb
station-0.4.8 lib/nexmo_developer/app/services/search/document.rb
station-0.4.7 lib/nexmo_developer/app/services/search/document.rb