Class: CharDetector::Engine
- Inherits:
-
Object
- Object
- CharDetector::Engine
- Defined in:
- lib/char_detector/engine.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(file:) ⇒ Engine
constructor
A new instance of Engine.
- #scan ⇒ Object
Constructor Details
#initialize(file:) ⇒ Engine
Returns a new instance of Engine.
3 4 5 |
# File 'lib/char_detector/engine.rb', line 3 def initialize(file:) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/char_detector/engine.rb', line 7 def file @file end |
Instance Method Details
#scan ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/char_detector/engine.rb', line 9 def scan matches = [] File.readlines(file).each_with_index do |line, index| if result = Line.new(index+1, line, /\p{Cntrl}/).scanline matches << result end end return matches end |