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



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

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



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

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
# File 'lib/renogen/change_log/item.rb', line 16

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