class Itex2MML::Parser

Public Class Methods

semaphore() click to toggle source
# File lib/itextomml.rb, line 53
def self.semaphore
  @semaphore ||= Mutex.new
end

Public Instance Methods

block_filter(string) click to toggle source
# File lib/itextomml.rb, line 69
def block_filter(string)
  parse("\$\$#{string}\$\$", :itex2MML_filter)
end
filter(string) click to toggle source
# File lib/itextomml.rb, line 61
def filter(string)
  parse(string, :itex2MML_filter)
end
html_filter(string) click to toggle source
# File lib/itextomml.rb, line 57
def html_filter(string)
  parse(string, :itex2MML_html_filter)
end
inline_filter(string) click to toggle source
# File lib/itextomml.rb, line 65
def inline_filter(string)
  parse("\$#{string}\$", :itex2MML_filter)
end

Private Instance Methods

as_bytes(string) click to toggle source
# File lib/itextomml.rb, line 84
def as_bytes(string)
  string.force_encoding("ASCII-8BIT")
end
as_utf8(string) click to toggle source
# File lib/itextomml.rb, line 87
def as_utf8(string)
  string.force_encoding("UTF-8")
end
parse(string, message) click to toggle source
# File lib/itextomml.rb, line 75
def parse(string, message)
  str = as_bytes(string.to_str)
  self.class.semaphore.synchronize do
    raise Itex2MML::Error unless Itex2MML.send(message, str, str.length) == 0
    as_utf8(Itex2MML.itex2MML_output)
  end
end