Module: RGhost::ParseText

Included in:
Text, TextArea
Defined in:
lib/rghost/parse_text.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#ta_entry(e, tag = "default_font") ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/rghost/parse_text.rb', line 43

def ta_entry(e,tag="default_font")
  if self.class == RGhost::Text and  @options[:text_align] == :left
    " :text _#{tag} #{to_string(e)} :text_proc "  
  elsif self.class == RGhost::TextArea and @options[:text_align] == :left
    " :text_area _#{tag} #{to_string(e)} :text_proc "  
  else
    "  _#{tag} #{to_string(e)} :text_proc_cr "  
  end
end

#text_to_psObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rghost/parse_text.rb', line 4

def text_to_ps
  
  unless @tag_parse
    case @options[:text_align]
    when :center, :right then
      @text.split(/\n/).map{|l| "#{to_string(l)} :text_proc_cr :nbw " }.to_s  
      jump_with=':nbw'
    when :left,nil then
      if self.class == RGhost::Text
        return @text.split(/\n/).map{|l| " :text #{to_string(l)} :text_proc nrdp " }.to_s 

      else
        @text.split(/\n/).map{|l| " :text_area #{to_string(l)} :text_proc_cr :nbw " }.to_s        
        jump_with='nrdp'
      end
    end
  end
  
  
  
  jump_with=':nbw' if self.class == RGhost::TextArea        
  
  
  ret=@text.split(/<br\/?>|\n/).map do |piece|
    text_ok=""
    piece.scan(/<([^>]+)>([^<]*.)<\/\1>|([^<>]+)/).each do |t|
      t.compact!
      if t && t.size == 1
        text_ok << ta_entry(t.first.to_s)
      else
        text_ok << ta_entry(t[1],t.first)
      end
    end
    text_ok
  end
  
  ret.join(" #{jump_with || 'nrdp' } ").gsub(/&lt/,'<').gsub(/&gt/,'>')
end