Class: String

Inherits:
Object show all
Defined in:
lib/ttk/symtbl.rb,
lib/ttk/dumpers/Xml.rb,
lib/ttk/loaders/Loader.rb,
lib/ttk/strategies/Streams.rb

Instance Method Summary collapse

Instance Method Details

#compare_stream(stream) ⇒ Object



48
49
50
# File 'lib/ttk/strategies/Streams.rb', line 48

def compare_stream ( stream )
  self == stream.read
end

#symtbl_gsub(symtbl) ⇒ Object



110
111
112
113
114
# File 'lib/ttk/symtbl.rb', line 110

def symtbl_gsub ( symtbl )
  return nil unless self =~ /<<(.*)>>/
  str = gsub(/<<(.*?)>>/) { symtbl[$1.to_sym] || $& }
  (str == self)? nil : str
end

#testify(opts = {}, &block) ⇒ Object



78
79
80
81
82
83
# File 'lib/ttk/loaders/Loader.rb', line 78

def testify ( opts={}, &block )
  unless opts.has_key? :loader
    raise ArgumentError, "No loader found in options (:loader)"
  end
  opts[:loader].load(self).testify(opts, &block)
end

#xmlizeObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/ttk/dumpers/Xml.rb', line 72

def xmlize
  count = -1
  ret = ''
  each_byte do |c|
    if count >= 80 then
      ret << "\\<br />" << c
      count = 0
    elsif c == ?\n then
      ret << '<br />'
      count = 0
    else
      ret << c
      count += 1
    end
  end
  ret
end

#xmlize_textObject



90
91
92
93
94
95
96
97
# File 'lib/ttk/dumpers/Xml.rb', line 90

def xmlize_text
  ret = xmlize
  if ret =~ /^[\w.,;!?\/@~+=*-]*$/
    ret
  else
    REXML::CData.new(ret)
  end
end