Class: GitHub::Markup::CommandImplementation

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

Instance Attribute Summary collapse

Attributes inherited from Implementation

#languages, #regexp

Instance Method Summary collapse

Methods inherited from Implementation

#load, #match?

Constructor Details

#initialize(regexp, languages, command, name, &block) ⇒ CommandImplementation

Returns a new instance of CommandImplementation.



18
19
20
21
22
23
# File 'lib/github/markup/command_implementation.rb', line 18

def initialize(regexp, languages, command, name, &block)
  super(regexp, languages)
  @command = command.to_s
  @block = block
  @name = name
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



16
17
18
# File 'lib/github/markup/command_implementation.rb', line 16

def block
  @block
end

#commandObject (readonly)

Returns the value of attribute command.



16
17
18
# File 'lib/github/markup/command_implementation.rb', line 16

def command
  @command
end

#nameObject (readonly)

Returns the value of attribute name.



16
17
18
# File 'lib/github/markup/command_implementation.rb', line 16

def name
  @name
end

Instance Method Details

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



25
26
27
28
29
# File 'lib/github/markup/command_implementation.rb', line 25

def render(filename, content, options: {})
  rendered = execute(command, content)
  rendered = rendered.to_s.empty? ? content : rendered
  call_block(rendered, content)
end