class Ruby2JS::Line

Attributes

indent[RW]

Public Class Methods

new(*args) click to toggle source
Calls superclass method
# File lib/ruby2js/serializer.rb, line 16
def initialize(*args)
  super(args)
  @indent = 0
end

Public Instance Methods

comment?() click to toggle source
# File lib/ruby2js/serializer.rb, line 21
def comment?
  first = find {|token| !token.empty?}
  first and first.start_with? '//'
end
empty?() click to toggle source
# File lib/ruby2js/serializer.rb, line 26
def empty?
  all? {|line| line.empty?}
end
to_s() click to toggle source
# File lib/ruby2js/serializer.rb, line 30
def to_s
  if empty?
    ''
  elsif ['case ', 'default:'].include? self[0]
    ' ' * ([0,indent-2].max) + join
  elsif indent > 0
    ' ' * indent + join
  else
    join
  end
end