class MarkdownRubyDocumentation::GitHubLink::FileUrl
Attributes
base_url[R]
file_path[R]
root[R]
Public Class Methods
new(file_path:, base_url: GitHubProject.url, root: GitHubProject.root_path)
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 27 def initialize(file_path:, base_url: GitHubProject.url, root: GitHubProject.root_path) @file_path = file_path @base_url = base_url @root = root end
Public Instance Methods
blob(file)
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 49 def blob(file) GitHubProject.branch end
link(file, lineno=nil)
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 41 def link(file, lineno=nil) str = File.join(base_url, "blob", blob(file), relative_path(file)) unless lineno.nil? str << "#L#{lineno}" end str.chomp.gsub("https://github.com///github.com/", "https://github.com/") end
relative_path(file)
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 53 def relative_path(file) file.sub(root, "") end
to_pathname()
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 37 def to_pathname Pathname(to_s) end
to_s()
click to toggle source
# File lib/markdown_ruby_documentation/git_hub_link.rb, line 33 def to_s link(file_path) end