Class: Adjutant::Comment

Inherits:
Struct
  • Object
show all
Defined in:
lib/adjutant/comment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeComment

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

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



2
3
4
# File 'lib/adjutant/comment.rb', line 2

def index
  @index
end

#textObject

Returns the value of attribute text

Returns:

  • (Object)

    the current value of 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

Returns:

  • (Boolean)


18
19
20
# File 'lib/adjutant/comment.rb', line 18

def empty?
  self.text.nil? || self.text.empty?
end


26
27
28
# File 'lib/adjutant/comment.rb', line 26

def print
  [ self.text, self.index ]
end

#resetObject



22
23
24
# File 'lib/adjutant/comment.rb', line 22

def reset
  self.text = nil
end