Class: SourceNotes::Extractor::Annotation
- Inherits:
-
Struct
- Object
- Struct
- SourceNotes::Extractor::Annotation
- Defined in:
- lib/source_notes.rb
Overview
Annotation objects are triplets :line
, :tag
, :text
that represent the line where the annotation lives, its tag, and its text. Note the filename is not stored.
Annotations are looked for in comments and modulus whitespace they have to start with the tag optionally followed by a colon. Everything up to the end of the line (or closing ERB comment tag) is considered to be their text.
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#to_s(options = {}) ⇒ Object
Returns a representation of the annotation that looks like this:.
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line
12 13 14 |
# File 'lib/source_notes.rb', line 12 def line @line end |
#tag ⇒ Object
Returns the value of attribute tag
12 13 14 |
# File 'lib/source_notes.rb', line 12 def tag @tag end |
#text ⇒ Object
Returns the value of attribute text
12 13 14 |
# File 'lib/source_notes.rb', line 12 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.
19 20 21 22 23 |
# File 'lib/source_notes.rb', line 19 def to_s(={}) s = "[#{line.to_s.rjust([:indent])}] " s << "[#{tag}] " if [:tag] s << text end |