Module: RBeautify

Defined in:
lib/ruby-beautify/lib/ruby-beautify.rb,
lib/ruby-beautify/lib/ruby-beautify/line.rb,
lib/ruby-beautify/lib/ruby-beautify/version.rb,
lib/ruby-beautify/lib/ruby-beautify/language.rb,
lib/ruby-beautify/lib/ruby-beautify/block_end.rb,
lib/ruby-beautify/lib/ruby-beautify/block_start.rb,
lib/ruby-beautify/lib/ruby-beautify/block_matcher.rb

Defined Under Namespace

Classes: BlockEnd, BlockMatcher, BlockStart, Language, Line

Constant Summary collapse

VERSION =
"0.92.2"

Class Method Summary collapse

Class Method Details

.beautify_string(language, source, use_tabs = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-beautify/lib/ruby-beautify.rb', line 10

def self.beautify_string(language, source, use_tabs=false)
  dest = ""
  block = nil

  unless language.is_a? RBeautify::Language
    language = RBeautify::Language.language(language)
  end

  source.lines.each_with_index do |line_content, line_number|
    line = RBeautify::Line.new(language, line_content, line_number, block, use_tabs)
    dest += line.format + "\n"
    block = line.block
  end

  return dest
end