Module: ANTLR3::Util

Included in:
AST::Wizard, Main::Main
Defined in:
lib/antlr3/util.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) parse_version(version_string)



17
18
19
20
21
# File 'lib/antlr3/util.rb', line 17

def parse_version( version_string )
  version_string.split( '.' ).map! do | segment |
    segment.to_i
  end.freeze
end

- (Object) silence_warnings



32
33
34
35
36
37
# File 'lib/antlr3/util.rb', line 32

def silence_warnings
  verbosity, $VERBOSE = $VERBOSE, nil
  return yield
ensure
  $VERBOSE = verbosity
end

- (Object) snake_case(str)



9
10
11
12
13
14
15
# File 'lib/antlr3/util.rb', line 9

def snake_case( str )
  str = str.to_s.gsub( /([A-Z]+)([A-Z][a-z])/,'\1_\2' )
  str.gsub!( /([a-z\d])([A-Z])/,'\1_\2' )
  str.tr!( "-", "_" )
  str.downcase!
  str
end

- (Object) tidy(here_doc, flow = false)



23
24
25
26
27
28
29
30
# File 'lib/antlr3/util.rb', line 23

def tidy( here_doc, flow = false )
  here_doc.gsub!( /^ *\| ?/, '' )
  if flow
    here_doc.strip!
    here_doc.gsub!( /\s+/, ' ' )
  end
  return here_doc
end