Class: GTDThing

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

Overview

Parse, model, and print a line too wide for its own good

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, line_number, line) ⇒ GTDThing

Returns a new instance of GTDThing.



84
85
86
87
88
# File 'lib/gtdlint.rb', line 84

def initialize(filename, line_number, line)
  @filename = filename
  @line_number = line_number
  @line = line
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



69
70
71
# File 'lib/gtdlint.rb', line 69

def filename
  @filename
end

#lineObject

Returns the value of attribute line.



69
70
71
# File 'lib/gtdlint.rb', line 69

def line
  @line
end

#line_numberObject

Returns the value of attribute line_number.



69
70
71
# File 'lib/gtdlint.rb', line 69

def line_number
  @line_number
end

Class Method Details

.parse(filename, grep_line) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/gtdlint.rb', line 71

def self.parse(filename, grep_line)
  if grep_line.match(/^--$/)
    grep_line
  else
    match = grep_line.match(/^([0-9]+)(\:|-)(.*)$/)

    line_number = match[1]
    line = match[3]

    GTDThing.new(filename, line_number, line)
  end
end

Instance Method Details

#to_sObject



90
91
92
# File 'lib/gtdlint.rb', line 90

def to_s
  "#{filename}:#{line_number}:#{line}"
end