Class: Watnow::AnnotationLine
- Inherits:
-
Object
- Object
- Watnow::AnnotationLine
- Defined in:
- lib/watnow/annotation/annotation_line.rb
Constant Summary collapse
- @@id =
0
- @@instances =
[]
- @@tag_length =
0
Instance Attribute Summary collapse
-
#annotation ⇒ Object
Returns the value of attribute annotation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lineno ⇒ Object
Returns the value of attribute lineno.
-
#mention ⇒ Object
Returns the value of attribute mention.
-
#message ⇒ Object
Returns the value of attribute message.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#tag ⇒ Object
Returns the value of attribute tag.
Class Method Summary collapse
-
.find(id) ⇒ Object
An ORM-like find method that returns an AnnotationLine instance.
-
.tag_length ⇒ Object
Returns longest tag length Used to format output.
Instance Method Summary collapse
-
#initialize(opts, annotation) ⇒ AnnotationLine
constructor
A new instance of AnnotationLine.
-
#meta_data ⇒ Object
Returns an array of “meta data” Namely: The AnnotationLine mention and priority.
Constructor Details
#initialize(opts, annotation) ⇒ AnnotationLine
Returns a new instance of AnnotationLine.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/watnow/annotation/annotation_line.rb', line 25 def initialize(opts, annotation) @lineno = opts[:lineno] @tag = opts[:tag] @priority = opts[:priority] || 0 @mention = opts[:mention] || '' @message = opts[:message] @annotation = annotation @annotation.priority = @priority if @priority > @annotation.priority # Auto increment instances id # Push instance into a class array @id = @@id += 1 @@instances << self # Update class’ tag_length to the longest tag @@tag_length = @tag.length if @tag.length > @@tag_length end |
Instance Attribute Details
#annotation ⇒ Object
Returns the value of attribute annotation.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def annotation @annotation end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def id @id end |
#lineno ⇒ Object
Returns the value of attribute lineno.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def lineno @lineno end |
#mention ⇒ Object
Returns the value of attribute mention.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def mention @mention end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def @message end |
#priority ⇒ Object
Returns the value of attribute priority.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def priority @priority end |
#tag ⇒ Object
Returns the value of attribute tag.
8 9 10 |
# File 'lib/watnow/annotation/annotation_line.rb', line 8 def tag @tag end |
Class Method Details
.find(id) ⇒ Object
An ORM-like find method that returns an AnnotationLine instance
11 12 13 14 15 16 17 |
# File 'lib/watnow/annotation/annotation_line.rb', line 11 def self.find(id) @@instances.each do |instance| return instance if instance.id == id end nil end |
.tag_length ⇒ Object
Returns longest tag length Used to format output
21 22 23 |
# File 'lib/watnow/annotation/annotation_line.rb', line 21 def self.tag_length @@tag_length end |
Instance Method Details
#meta_data ⇒ Object
Returns an array of “meta data” Namely: The AnnotationLine mention and priority
46 47 48 49 50 51 |
# File 'lib/watnow/annotation/annotation_line.rb', line 46 def data = [] data << "@#{@mention}" unless @mention.empty? data << Array.new(@priority + 1).join('!') if @priority > 0 data end |