Class: ImprovePagePresenter

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo_developer/app/presenters/improve_page_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(document_path) ⇒ ImprovePagePresenter

Returns a new instance of ImprovePagePresenter.



2
3
4
# File 'lib/nexmo_developer/app/presenters/improve_page_presenter.rb', line 2

def initialize(document_path)
  @document_path = document_path
end

Instance Method Details

#docs_repoObject



10
11
12
13
14
# File 'lib/nexmo_developer/app/presenters/improve_page_presenter.rb', line 10

def docs_repo
  @docs_repo ||= begin
    path_to_url.start_with?('lib/nexmo_developer/app/') ? 'nexmo/station' : YAML.safe_load(File.open("#{Rails.configuration.docs_base_path}/config/business_info.yml"))['docs_repo']
  end
end

#github_urlObject



6
7
8
# File 'lib/nexmo_developer/app/presenters/improve_page_presenter.rb', line 6

def github_url
  @github_url ||= "https://github.com/#{docs_repo}/blob/#{ENV.fetch('branch', 'main')}/#{path_to_url}"
end

#path_to_urlObject



16
17
18
19
20
21
# File 'lib/nexmo_developer/app/presenters/improve_page_presenter.rb', line 16

def path_to_url
  @path_to_url ||= begin
    @document_path&.gsub!("#{Rails.configuration.docs_base_path}/", '')
    @document_path.start_with?('app/views') ? @document_path.prepend('lib/nexmo_developer/') : @document_path
  end
end