Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • xsd/codegen/gensupport.rb

Class/Module Index [+]

Quicksearch

XSD::CodeGen::GenSupport

Public Class Methods

capitalize(target) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 58
def capitalize(target)
  target.sub(/^([a-z])/) { $1.tr!('[a-z]', '[A-Z]') }
end
            
keyword?(word) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 114
def keyword?(word)
  KEYWORD.key?(word)
end
            
safeconstname(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 68
def safeconstname(name)
  safename = name.scan(/[a-zA-Z0-9_]+/).collect { |ele|
    GenSupport.capitalize(ele)
  }.join
  if /^[A-Z]/ !~ safename or keyword?(safename)
    safename = "C_#{safename}"
  end
  safename
end
            
safeconstname?(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 79
def safeconstname?(name)
  /\A[A-Z][a-zA-Z0-9_]*\z/ =~ name and !keyword?(name)
end
            
safemethodname(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 84
def safemethodname(name)
  safename = name.scan(/[a-zA-Z0-9_]+/).join('_')
  safename = uncapitalize(safename)
  if /^[a-z]/ !~ safename
    safename = "m_#{safename}"
  end
  safename
end
            
safemethodname?(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 94
def safemethodname?(name)
  /\A[a-zA-Z_][a-zA-Z0-9_]*[=!?]?\z/ =~ name
end
            
safevarname(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 99
def safevarname(name)
  safename = uncapitalize(name.scan(/[a-zA-Z0-9_]+/).join('_'))
  if /^[a-z]/ !~ safename or keyword?(safename)
    "v_#{safename}"
  else
    safename
  end
end
            
safevarname?(name) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 109
def safevarname?(name)
  /\A[a-z_][a-zA-Z0-9_]*\z/ =~ name and !keyword?(name)
end
            
uncapitalize(target) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 63
def uncapitalize(target)
  target.sub(/^([A-Z])/) { $1.tr!('[A-Z]', '[a-z]') }
end
            

Public Instance Methods

format(str, indent = nil) click to toggle source
 
               # File xsd/codegen/gensupport.rb, line 119
def format(str, indent = nil)
  str = trim_eol(str)
  str = trim_indent(str)
  if indent
    str.gsub(/^/, " " * indent)
  else
    str
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus