Class: Issuesrc::Tag
- Inherits:
-
Object
- Object
- Issuesrc::Tag
- Defined in:
- lib/issuesrc/tag.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#begin_pos ⇒ Object
readonly
Returns the value of attribute begin_pos.
-
#end_pos ⇒ Object
readonly
Returns the value of attribute end_pos.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#issue_id ⇒ Object
Returns the value of attribute issue_id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(label, issue_id, author, title, file, line, begin_pos, end_pos) ⇒ Tag
constructor
A new instance of Tag.
- #to_s ⇒ Object
- #write_in_file(offsets) ⇒ Object
Constructor Details
#initialize(label, issue_id, author, title, file, line, begin_pos, end_pos) ⇒ Tag
Returns a new instance of Tag.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/issuesrc/tag.rb', line 12 def initialize(label, issue_id, , title, file, line, begin_pos, end_pos) @label = label @issue_id = issue_id.nil? || issue_id.empty? ? nil : issue_id @author = .nil? || .empty? ? nil : @title = title @file = file @line = line @begin_pos = begin_pos @end_pos = end_pos end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
5 6 7 |
# File 'lib/issuesrc/tag.rb', line 5 def @author end |
#begin_pos ⇒ Object (readonly)
Returns the value of attribute begin_pos.
9 10 11 |
# File 'lib/issuesrc/tag.rb', line 9 def begin_pos @begin_pos end |
#end_pos ⇒ Object (readonly)
Returns the value of attribute end_pos.
10 11 12 |
# File 'lib/issuesrc/tag.rb', line 10 def end_pos @end_pos end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/issuesrc/tag.rb', line 7 def file @file end |
#issue_id ⇒ Object
Returns the value of attribute issue_id.
4 5 6 |
# File 'lib/issuesrc/tag.rb', line 4 def issue_id @issue_id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
3 4 5 |
# File 'lib/issuesrc/tag.rb', line 3 def label @label end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
8 9 10 |
# File 'lib/issuesrc/tag.rb', line 8 def line @line end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/issuesrc/tag.rb', line 6 def title @title end |
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/issuesrc/tag.rb', line 24 def to_s ret = "" ret << @label if !@issue_id.nil? || !@author.nil? ret << '(' if !@author.nil? ret << @author end if !@issue_id.nil? ret << '#' << @issue_id end ret << ')' end if !@title.nil? ret << ': ' << @title.strip end ret end |
#write_in_file(offsets) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/issuesrc/tag.rb', line 43 def write_in_file(offsets) total_offset = 0 offsets.each do |pos, offset| if pos <= @begin_pos total_offset += offset end end old_begin_pos = @begin_pos @begin_pos += total_offset @end_pos += total_offset file.replace_at(@begin_pos, @end_pos-@begin_pos, to_s()) new_end_pos = @begin_pos + to_s.length offset = new_end_pos - @end_pos @end_pos = new_end_pos offsets << [old_begin_pos, offset] offsets end |