Class: Coradoc::Element::Revision

Inherits:
Base
  • Object
show all
Defined in:
lib/coradoc/element/revision.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#children_accessors, children_accessors, declare_children, #simplify_block_content, visit, #visit

Constructor Details

#initialize(number, options = {}) ⇒ Revision

Returns a new instance of Revision.



8
9
10
11
12
# File 'lib/coradoc/element/revision.rb', line 8

def initialize(number, options = {})
  @number = number
  @date = options.fetch(:date, nil)
  @remark = options.fetch(:remark, nil)
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/coradoc/element/revision.rb', line 4

def date
  @date
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/coradoc/element/revision.rb', line 4

def number
  @number
end

#remarkObject

Returns the value of attribute remark.



4
5
6
# File 'lib/coradoc/element/revision.rb', line 4

def remark
  @remark
end

Instance Method Details

#to_adocObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/coradoc/element/revision.rb', line 14

def to_adoc
  if @date.nil? && @remark.nil?
    "v#{@number}\n"
  elsif @remark.nil?
    "#{@number}, #{@date}\n"
  elsif @date.nil?
    "#{@number}: #{@remark}\n"
  else
    "#{@number}, #{@date}: #{@remark}\n"
  end
end