Class: Crosstest::Psychic::CodeHelper::ReStructuredTextHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/crosstest/psychic/code_helper.rb

Class Method Summary collapse

Class Method Details

.code_block(source, language) ⇒ Object


24
25
26
27
28
29
30
31
32
# File 'lib/crosstest/psychic/code_helper.rb', line 24

def self.code_block(source, language)
  buffer = StringIO.new
  buffer.puts ".. code-block:: #{language}"
  indented_source = source.lines.map do|line|
    "  #{line}"
  end.join("\n")
  buffer.puts indented_source
  buffer.string
end