lib/rmagick_internal.rb
# Draw text at position x,y. Add quotes to text that is not already quoted.
Draw text at position x,y. Add quotes to text that is not already quoted.
Draw text at position x y . Add quotes to text that is not already quoted .
def text(x, y, text)
      Kernel.raise ArgumentError, 'missing text argument' if text.to_s.empty?
      if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text)
      elsif !text['\'']
        text = '\'' + text + '\''
      elsif !text['"']
        text = '"' + text + '"'
      elsif !(text['{'] || text['}'])
        text = '{' + text + '}'
      else
        text = '{' + text.gsub(/[}]/) { |b| '\\' + b } + '}'
      end
      primitive 'text ' + sprintf('%g,%g %s', x, y, text)
    end
def text ( x , y , text ) Kernel . raise ArgumentError , 'missing text argument' if text . to_s . empty? if text . length > 2 && / \A (?: \" [^ \" ]+ \" | \' [^ \' ]+ \' | \{ [^ \} ]+ \} ) \z / . match ( text ) elsif ! text [ '\'' ] text = '\'' + text + '\'' elsif ! text [ '"' ] text = '"' + text + '"' elsif ! ( text [ '{' ] || text [ '}' ] ) text = '{' + text + '}' else text = '{' + text . gsub ( / [}] / ) { | b | '\\' + b } + '}' end primitive 'text ' + sprintf ( '%g,%g %s' , x , y , text ) end
Draw text at position x,y.
Draw text at position x y .
# text already quoted # escape existing braces, surround with braces
x
<not_specific>
y
<not_specific>
text
<not_specific>