Class: Zeiger::Line
- Inherits:
-
Object
- Object
- Zeiger::Line
- Defined in:
- lib/zeiger/line.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#file ⇒ Object
Returns the value of attribute file.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(file, line_number, content) ⇒ Line
constructor
A new instance of Line.
- #matches?(regex) ⇒ Boolean
- #ngram_list(size) ⇒ Object
- #ngrams(size) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(file, line_number, content) ⇒ Line
Returns a new instance of Line.
6 7 8 9 |
# File 'lib/zeiger/line.rb', line 6 def initialize file, line_number, content @file, @line_number, @content = file, line_number, content @hash = "#{file.filename}##{line_number}".hash end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/zeiger/line.rb', line 3 def content @content end |
#file ⇒ Object
Returns the value of attribute file.
3 4 5 |
# File 'lib/zeiger/line.rb', line 3 def file @file end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
4 5 6 |
# File 'lib/zeiger/line.rb', line 4 def hash @hash end |
#line_number ⇒ Object
Returns the value of attribute line_number.
3 4 5 |
# File 'lib/zeiger/line.rb', line 3 def line_number @line_number end |
Instance Method Details
#==(other) ⇒ Object
15 |
# File 'lib/zeiger/line.rb', line 15 def == other ; self.file == other.file && self.line_number == other.line_number ; end |
#matches?(regex) ⇒ Boolean
12 |
# File 'lib/zeiger/line.rb', line 12 def matches? regex ; content.match regex ; end |
#ngram_list(size) ⇒ Object
13 |
# File 'lib/zeiger/line.rb', line 13 def ngram_list size ; @ngrams ||= content.ngrams(size) ; end |
#ngrams(size) ⇒ Object
14 |
# File 'lib/zeiger/line.rb', line 14 def ngrams size ; ngram_list(size).each { |ngram| yield ngram, self } ; end |
#to_s ⇒ Object
11 |
# File 'lib/zeiger/line.rb', line 11 def to_s ; "#{file.local_filename}:#{line_number}:#{content}" ; end |