Class: Rake::Notes::SourceAnnotationExtractor::Annotation

Inherits:
Struct
  • Object
show all
Defined in:
lib/rake/notes/source_annotation_extractor.rb

Constant Summary collapse

COLORS =
{
  'OPTIMIZE' => 'cyan',
  'FIXME' => 'magenta',
  'TODO' => 'yellow'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



25
26
27
# File 'lib/rake/notes/source_annotation_extractor.rb', line 25

def line
  @line
end

#tagObject

Returns the value of attribute tag

Returns:

  • (Object)

    the current value of tag



25
26
27
# File 'lib/rake/notes/source_annotation_extractor.rb', line 25

def tag
  @tag
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of text



25
26
27
# File 'lib/rake/notes/source_annotation_extractor.rb', line 25

def text
  @text
end

Instance Method Details

#to_s(options = {}) ⇒ Object

Returns a representation of the annotation that looks like this:

[126] [TODO] This algorithm is simple and clearly correct, make it faster.

If options has a flag :tag the tag is shown as in the example above. Otherwise the string contains just line and text.



39
40
41
42
43
44
# File 'lib/rake/notes/source_annotation_extractor.rb', line 39

def to_s(options={})
  colored_tag = COLORS[tag.to_s].nil? ? tag : tag.send(COLORS[tag.to_s])
  s = "[#{line.to_s.rjust(options[:indent]).green}] "
  s << "[#{colored_tag}] " if options[:tag]
  s << text
end