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.



12
13
14
15
16
# File 'lib/github/markup/command_implementation.rb', line 12

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.



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

def block
  @block
end

#commandObject (readonly)

Returns the value of attribute command.



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

def command
  @command
end

Instance Method Details

#render(content) ⇒ Object



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

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