class Search::Article

Public Class Methods

new(doc, html) click to toggle source
# File lib/nexmo_developer/app/services/search/article.rb, line 5
def initialize(doc, html)
  @doc  = doc
  @html = html
end

Public Instance Methods

product() click to toggle source
# File lib/nexmo_developer/app/services/search/article.rb, line 14
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
relative_path() click to toggle source
# File lib/nexmo_developer/app/services/search/article.rb, line 10
def relative_path
  @relative_path ||= "#{config[:base_url_path]}/#{path.relative_path_from(config[:origin])}".gsub('.md', '')
end
to_h() click to toggle source
# File lib/nexmo_developer/app/services/search/article.rb, line 25
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