Class: Adjutant::Comment
- Inherits:
-
Struct
- Object
- Struct
- Adjutant::Comment
- Defined in:
- lib/adjutant/comment.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #add(comment, index) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ Comment
constructor
A new instance of Comment.
- #print ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Comment
Returns a new instance of Comment.
3 4 5 6 |
# File 'lib/adjutant/comment.rb', line 3 def initialize(*) super self.index ||= 0 end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index
2 3 4 |
# File 'lib/adjutant/comment.rb', line 2 def index @index end |
#text ⇒ Object
Returns the value of attribute text
2 3 4 |
# File 'lib/adjutant/comment.rb', line 2 def text @text end |
Instance Method Details
#add(comment, index) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/adjutant/comment.rb', line 8 def add(comment, index) self.index = index + 1 if empty? self.text = if empty? comment.to_s else "#{self.text}\n#{comment}" end end |
#empty? ⇒ Boolean
18 19 20 |
# File 'lib/adjutant/comment.rb', line 18 def empty? self.text.nil? || self.text.empty? end |
#print ⇒ Object
26 27 28 |
# File 'lib/adjutant/comment.rb', line 26 def print [ self.text, self.index ] end |
#reset ⇒ Object
22 23 24 |
# File 'lib/adjutant/comment.rb', line 22 def reset self.text = nil end |