Class: Rubyfmt::Processor

Inherits:
Ruby2Ruby
  • Object
show all
Defined in:
lib/rubyfmt.rb

Instance Method Summary collapse

Instance Method Details

#indent(s) ⇒ Object



34
35
36
# File 'lib/rubyfmt.rb', line 34

def indent(s)
  super.split(/\n/).map {|line| line.strip.size == 0 ? '' : line }.join("\n")
end

#process_call(exp) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/rubyfmt.rb', line 23

def process_call(exp)
  methods_without_parens = [:puts]
  method = exp[1]
  
  if methods_without_parens.include?(method)
    super.sub(/^(#{method})\((.*)\)$/, '\1 \2')
  else
    super
  end
end

#process_class(exp) ⇒ Object



11
12
13
# File 'lib/rubyfmt.rb', line 11

def process_class(exp)
  super + "\n"
end

#process_if(exp) ⇒ Object



15
16
17
# File 'lib/rubyfmt.rb', line 15

def process_if(exp)
  super.sub(/\ then$/, '')
end

#process_while(exp) ⇒ Object



19
20
21
# File 'lib/rubyfmt.rb', line 19

def process_while(exp)
  super.sub(/\ do$/, '')
end