Class: Renogen::ChangeLog::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/renogen/change_log/item.rb

Overview

Object to represent single change item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_name, change, options = {}) ⇒ Item

Returns a new instance of Item.



8
9
10
11
# File 'lib/renogen/change_log/item.rb', line 8

def initialize(group_name, change, options={})
  @group_name = group_name
  @change = change
end

Instance Attribute Details

#changeObject

Returns the value of attribute change.



5
6
7
# File 'lib/renogen/change_log/item.rb', line 5

def change
  @change
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



6
7
8
# File 'lib/renogen/change_log/item.rb', line 6

def group_name
  @group_name
end

Instance Method Details

#eachObject

Iterater for each item within the change



36
37
38
39
40
# File 'lib/renogen/change_log/item.rb', line 36

def each
  change.each do |item|
    yield item.to_s
  end
end

#list?Boolean

Returns true if change is of type array.

Returns:

  • (Boolean)

    true if change is of type array



31
32
33
# File 'lib/renogen/change_log/item.rb', line 31

def list?
  change.is_a? Array
end

#to_sString

Coverts the item into its string representation

Returns:

  • (String)


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/renogen/change_log/item.rb', line 16

def to_s
  return '' unless change
  case change.class.to_s
  when 'String'
    format_multiline(change)
  when 'Hash'
    format_oneline(change)
  when 'Array'
    format_array(change)
  else
    raise TypeError
  end
end