Method: Flatulent#element!

Defined in:
lib/flatulent.rb

#element!Object

–}}}



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/flatulent.rb', line 483

def element!  #--{{{
  rows = []
  rows << (row = [])
  chars = @captcha.split %r//
  #chars = @figlet.split %r//
  size = chars.size
  last = size - 1

  chars.each_with_index do |char, idx|
    content = 
      case char 
      when %r/\n/o
        #"<br>"
        "\n"
      when %r/\s/o
        #"&nbsp;"
        " "
      when %r/([^\s])/o
        CGI.escapeHTML $1 
      end
      #Array.new(rand(10)){ content = "<span>#{ content }</span>"}
      row << content 
      rows << (row = []) unless idx == last 
  end

  content = rows.join
    #<table width='50%' border=1 bgcolor='#{ style["background"] }'><tr><td>
   #</td></tr></table>
  @element = "      <div id='\#{ @id }_element' style='\#{ css }'>\#{ content }</div>\n  html\nend\n"