Class: CharDet::CharSetProber

Inherits:
Object
  • Object
show all
Defined in:
lib/rchardet/charsetprober.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCharSetProber

Returns a new instance of CharSetProber.



33
34
# File 'lib/rchardet/charsetprober.rb', line 33

def initialize
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



32
33
34
# File 'lib/rchardet/charsetprober.rb', line 32

def active
  @active
end

Instance Method Details

#confidenceObject



44
45
46
# File 'lib/rchardet/charsetprober.rb', line 44

def confidence
  return 0.0
end

#filter_high_bit_only(aBuf) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/rchardet/charsetprober.rb', line 53

def filter_high_bit_only(aBuf)
  # DO NOT USE `gsub!`
  # It will remove all characters from the buffer that is later used by
  # other probers.  This is because gsub! removes data from the instance variable
  # that will be passed to later probers, while gsub makes a new instance variable
  # that will not.
  newBuf = aBuf.gsub(/([\x00-\x7F])+/, ' ')
  return newBuf
end

#filter_with_english_letters(aBuf) ⇒ Object



68
69
70
71
# File 'lib/rchardet/charsetprober.rb', line 68

def filter_with_english_letters(aBuf)
  # TODO
  return aBuf
end

#filter_without_english_letters(aBuf) ⇒ Object



63
64
65
66
# File 'lib/rchardet/charsetprober.rb', line 63

def filter_without_english_letters(aBuf)
  newBuf = aBuf.gsub(/([A-Za-z])+/,' ')
  return newBuf
end

#resetObject



36
37
38
# File 'lib/rchardet/charsetprober.rb', line 36

def reset
  @_mState = EDetecting
end

#resultObject



48
49
50
51
# File 'lib/rchardet/charsetprober.rb', line 48

def result
  { encoding: Encoding.find(charset_name),
    confidence: confidence }
end

#stateObject



40
41
42
# File 'lib/rchardet/charsetprober.rb', line 40

def state
  return @_mState
end