Class: GitHub::Markup::GemImplementation

Inherits:
Implementation show all
Defined in:
lib/github/markup/gem_implementation.rb

Instance Attribute Summary collapse

Attributes inherited from Implementation

#languages, #regexp

Instance Method Summary collapse

Methods inherited from Implementation

#match?

Constructor Details

#initialize(regexp, languages, gem_name, &renderer) ⇒ GemImplementation

Returns a new instance of GemImplementation.



8
9
10
11
12
# File 'lib/github/markup/gem_implementation.rb', line 8

def initialize(regexp, languages, gem_name, &renderer)
  super(regexp, languages)
  @gem_name = gem_name.to_s
  @renderer = renderer
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



6
7
8
# File 'lib/github/markup/gem_implementation.rb', line 6

def gem_name
  @gem_name
end

#rendererObject (readonly)

Returns the value of attribute renderer.



6
7
8
# File 'lib/github/markup/gem_implementation.rb', line 6

def renderer
  @renderer
end

Instance Method Details

#loadObject



14
15
16
17
18
# File 'lib/github/markup/gem_implementation.rb', line 14

def load
  return if defined?(@loaded) && @loaded
  require gem_name
  @loaded = true
end

#nameObject



25
26
27
# File 'lib/github/markup/gem_implementation.rb', line 25

def name
  gem_name
end

#render(filename, content, options: {}) ⇒ Object



20
21
22
23
# File 'lib/github/markup/gem_implementation.rb', line 20

def render(filename, content, options: {})
  load
  renderer.call(filename, content, options: options)
end