Class: Jekyll::GitHubMetadata::EditLinkTag

Inherits:
Liquid::Tag
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/jekyll-github-metadata/edit-link-tag.rb

Constant Summary collapse

MISSING_DATA_MSG =
"Cannot generate edit URLs due to missing site.github data".freeze
%r!(?:\"(.*)\"|'(.*)')!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/jekyll-github-metadata/edit-link-tag.rb', line 4

def context
  @context
end

Class Method Details

.def_hash_delegator(hash_method, key, method, default = nil) ⇒ Object

Defines an instance method that delegates to a hash’s key

hash_method - a symbol representing the instance method to delegate to. The

instance method should return a hash or respond to #[]

key - the key to call within the hash method - (optional) the instance method the key should be aliased to.

If not specified, defaults to the hash key

default - (optional) value to return if value is nil (defaults to nil)

Returns a symbol representing the instance method



16
17
18
19
20
21
22
23
24
25
# File 'lib/jekyll-github-metadata/edit-link-tag.rb', line 16

def self.def_hash_delegator(hash_method, key, method, default = nil)
  define_method(method) do
    hash = send(hash_method)
    if hash.respond_to? :[]
      hash[key.to_s] || default
    else
      default
    end
  end
end

Instance Method Details

#render(context) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/jekyll-github-metadata/edit-link-tag.rb', line 38

def render(context)
  @context = context
  if link_text
    link
  else
    uri.to_s
  end
end