Class: MarkdownRubyDocumentation::GitHubLink
- Inherits:
-
Object
- Object
- MarkdownRubyDocumentation::GitHubLink
- Defined in:
- lib/markdown_ruby_documentation/git_hub_link.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #call(hash) ⇒ Object
- #create_link(name: nil, method_object: nil, context: Kernel) ⇒ Object
-
#initialize(subject:, base_url: GitHubProject.url, root: GitHubProject.root_path) ⇒ GitHubLink
constructor
A new instance of GitHubLink.
Constructor Details
#initialize(subject:, base_url: GitHubProject.url, root: GitHubProject.root_path) ⇒ GitHubLink
Returns a new instance of GitHubLink.
5 6 7 8 9 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 5 def initialize(subject:, base_url: GitHubProject.url, root: GitHubProject.root_path) @subject = subject @base_url = base_url @root = root end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
3 4 5 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 3 def base_url @base_url end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
3 4 5 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 3 def root @root end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
3 4 5 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 3 def subject @subject end |
Instance Method Details
#call(hash) ⇒ Object
11 12 13 14 15 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 11 def call(hash) hash.each do |name, values| hash[name][:text] = "#{values[:text]}\n\n[show on github](#{create_link(name: name, method_object: values[:method_object], context: subject)})" end end |
#create_link(name: nil, method_object: nil, context: Kernel) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/markdown_ruby_documentation/git_hub_link.rb', line 17 def create_link(name: nil, method_object: nil, context: Kernel) if name && method_object.nil? method_object = Method.create("##{name}", context: context) end MethodUrl.new(subject: subject, base_url: base_url, root: root, method_object: method_object).to_s end |