Class: ToDo

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

Overview

TODO: example.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linenumber, summary, context) ⇒ ToDo

Returns a new instance of ToDo.



51
52
53
54
55
# File 'lib/drupal/todo_list.rb', line 51

def initialize (linenumber, summary, context)
  @linenumber = linenumber
  @summary = summary
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



49
50
51
# File 'lib/drupal/todo_list.rb', line 49

def context
  @context
end

#linenumberObject

Returns the value of attribute linenumber.



49
50
51
# File 'lib/drupal/todo_list.rb', line 49

def linenumber
  @linenumber
end

#summaryObject

Returns the value of attribute summary.



49
50
51
# File 'lib/drupal/todo_list.rb', line 49

def summary
  @summary
end

Class Method Details

.extract_context(linenumber, file) ⇒ Object



66
67
68
69
70
71
# File 'lib/drupal/todo_list.rb', line 66

def ToDo.extract_context(linenumber, file)
  file.rewind
  list = file.to_a
  #rewind one line (one line above) then add the line itself and three lines below.
  list.slice!(linenumber - 1, 5)
end

.extract_summary(line) ⇒ Object



61
62
63
64
# File 'lib/drupal/todo_list.rb', line 61

def ToDo.extract_summary(line)
  matches = line.match /(?:#|\/\/|\/\*|@)[\s]*todo:?[\s]*(.+)$/i
  matches[1] unless matches.nil? || matches.length <= 0
end

Instance Method Details

#to_sObject



57
58
59
# File 'lib/drupal/todo_list.rb', line 57

def to_s
  "#{@linenumber}: #{@summary}\n#{@context}\n"
end