Class: Bcat::TextFilter

Inherits:
Object
  • Object
show all
Includes:
Rack::Utils
Defined in:
lib/bcat/reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(source, force = false) ⇒ TextFilter

Returns a new instance of TextFilter.


87
88
89
90
# File 'lib/bcat/reader.rb', line 87

def initialize(source, force=false)
  @source = source
  @force = force
end

Instance Method Details

#each {|"<pre>"| ... } ⇒ Object

Yields:

  • ("<pre>")

92
93
94
95
96
97
98
99
100
# File 'lib/bcat/reader.rb', line 92

def each
  yield "<pre>"
  @source.each do |chunk|
    chunk = escape_html(chunk)
    chunk = "<span>#{chunk}</span>" if !chunk.gsub!(/\n/, "<br>")
    yield chunk
  end
  yield "</pre>"
end