Class: HTML2AsciiMath::Detector
- Inherits:
-
UnicodeScanner
- Object
- UnicodeScanner
- HTML2AsciiMath::Detector
- Defined in:
- lib/html2asciimath/detector.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ Detector
constructor
A new instance of Detector.
- #replace(&block) ⇒ Object
Constructor Details
#initialize(str) ⇒ Detector
Returns a new instance of Detector.
9 10 11 |
# File 'lib/html2asciimath/detector.rb', line 9 def initialize(str) super(str.dup) end |
Instance Method Details
#replace(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/html2asciimath/detector.rb', line 13 def replace(&block) scan_for_math do |math_start, math_end, score| range = (math_start...math_end) source_math = string[range] target_math = yield source_math string[range] = target_math self.pos += (target_math.size - source_math.size) end string end |