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(ticket_id, group_name, change, options = {}) ⇒ Item



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

def initialize(ticket_id, group_name, change, options={})
  @ticket_id = ticket_id
  @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

#ticket_idObject (readonly)

Returns the value of attribute ticket_id.



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

def ticket_id
  @ticket_id
end

Instance Method Details

#eachObject

Iterater for each item within the change



38
39
40
41
42
# File 'lib/renogen/change_log/item.rb', line 38

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

#list?Boolean



33
34
35
# File 'lib/renogen/change_log/item.rb', line 33

def list?
  change.is_a? Array
end

#to_sString

Coverts the item into its string representation



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

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