Class: CharDetector::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/char_detector/line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number, content, pattern) ⇒ Line

Returns a new instance of Line.



3
4
5
6
7
# File 'lib/char_detector/line.rb', line 3

def initialize(number, content, pattern)
  @number  = number
  @content = content
  @pattern = pattern
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



9
10
11
# File 'lib/char_detector/line.rb', line 9

def content
  @content
end

#numberObject (readonly)

Returns the value of attribute number.



9
10
11
# File 'lib/char_detector/line.rb', line 9

def number
  @number
end

#patternObject (readonly)

Returns the value of attribute pattern.



9
10
11
# File 'lib/char_detector/line.rb', line 9

def pattern
  @pattern
end

Instance Method Details

#scanlineObject



11
12
13
14
15
16
17
18
19
# File 'lib/char_detector/line.rb', line 11

def scanline
  return nil if matched_chars.empty? # TODO null object pattern?

  hash = {}
  hash[:line]    = number
  hash[:columns] = matched_columns

  return hash
end