Class: Search::Article
- Inherits:
-
Object
- Object
- Search::Article
- Defined in:
- lib/nexmo_developer/app/services/search/article.rb
Instance Method Summary collapse
-
#initialize(doc, html) ⇒ Article
constructor
A new instance of Article.
- #product ⇒ Object
- #relative_path ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(doc, html) ⇒ Article
Returns a new instance of Article.
5 6 7 8 |
# File 'lib/nexmo_developer/app/services/search/article.rb', line 5 def initialize(doc, html) @doc = doc @html = html end |
Instance Method Details
#product ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# 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 ⇒ Object
10 11 12 |
# 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 ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 |