Class: Doing::Entry

Inherits:
Object show all
Defined in:
lib/doing/changelog/entry.rb

Overview

An individual changelog item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, type, prefix: false) ⇒ Entry

Returns a new instance of Entry.



10
11
12
13
14
# File 'lib/doing/changelog/entry.rb', line 10

def initialize(string, type, prefix: false)
  @string = string
  @type = type
  @prefix = prefix
end

Instance Attribute Details

#prefix=(value) ⇒ Object (writeonly)

Sets the attribute prefix

Parameters:

  • value

    the value to set the attribute prefix to.



8
9
10
# File 'lib/doing/changelog/entry.rb', line 8

def prefix=(value)
  @prefix = value
end

#stringObject (readonly)

Returns the value of attribute string.



6
7
8
# File 'lib/doing/changelog/entry.rb', line 6

def string
  @string
end

#typeObject (readonly)

Returns the value of attribute type.



6
7
8
# File 'lib/doing/changelog/entry.rb', line 6

def type
  @type
end

Instance Method Details

#clean(string) ⇒ Object



16
17
18
# File 'lib/doing/changelog/entry.rb', line 16

def clean(string)
  string.gsub(/\|/, '\|')
end


20
21
22
# File 'lib/doing/changelog/entry.rb', line 20

def print_prefix
  @prefix ? "#{@type}: " : ''
end

#to_sObject



24
25
26
# File 'lib/doing/changelog/entry.rb', line 24

def to_s
  "- #{print_prefix}#{clean(@string)}"
end