Class: GitHub::Markup::CommandImplementation

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

Instance Attribute Summary collapse

Attributes inherited from Implementation

#regexp

Instance Method Summary collapse

Methods inherited from Implementation

#load, #match?

Constructor Details

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

Returns a new instance of CommandImplementation.



9
10
11
12
13
# File 'lib/github/markup/command_implementation.rb', line 9

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



7
8
9
# File 'lib/github/markup/command_implementation.rb', line 7

def block
  @block
end

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/github/markup/command_implementation.rb', line 7

def command
  @command
end

Instance Method Details

#render(content) ⇒ Object



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

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