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"
%r!(?:\"(.*)\"|'(.*)')!.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

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



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

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



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

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