Class: CGenerator::CFragment::StatementAccumulator

Inherits:
Accumulator
  • Object
show all
Defined in:
lib/cgen/cgen.rb

Instance Attribute Summary

Attributes inherited from Accumulator

#name, #parent

Instance Method Summary collapse

Methods inherited from Accumulator

#accept?, #add, #add_one, #initialize, #inspect, #inspect_one, #output, #separator, #to_s

Constructor Details

This class inherits a constructor from CGenerator::Accumulator

Instance Method Details

#add_one_really(item) ⇒ Object



1320
1321
1322
1323
1324
1325
1326
# File 'lib/cgen/cgen.rb', line 1320

def add_one_really item
  if item.kind_of? String
    super item.tabto(0)
  else
    super
  end
end

#output_one(item) ⇒ Object



1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
# File 'lib/cgen/cgen.rb', line 1328

def output_one item
  case item
  when Array
    str = item.join("") ## 1.9 compatibility
  else
    str = item.to_s
  end
#      if str =~ /(?:\A|[;}])\s*\z/
  if str.empty? or str =~ /[\s;}]\z/ or str =~ /\A\s*(?:\/\/|#)/
    str
  else
    str + ';'
  end
end