Class: KeytechKit::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/keytechKit/elements/element.rb

Overview

Represents a single element

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Element

Returns a new instance of Element.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/keytechKit/elements/element.rb', line 28

def initialize(data)
  @key = data['Key']
  @name = data['Name']
  set_key_value_list(data['KeyValueList'])


  @classDisplayName = data['ClassDisplayName']
  @version = data['Version']
  @status = data['Status']
  @description = data['Description']

  @changedBy = data['ChangedBy']
  @changedByLong = data['ChangedByLong']
  @changedAt = data['ChangedAt']

  @createdBy = data['CreatedBy']
  @createdByLong = data['CreatedByLong']
  @createdAt = data['CreatedAt']

  @thumbnailHint = data['ThumbnailHint']
  @hasVersions = data['HasVersions']

  class_key = Tools.class_key(@key)
  project_classes = %w[TASK_WF MAIL_WF]
  @displayname = if project_classes.include?(class_key)
                   data['Subject']
                 else
                   data['DisplayName']
                 end
end

Instance Attribute Details

#changedAtObject

Returns the value of attribute changedAt.



16
17
18
# File 'lib/keytechKit/elements/element.rb', line 16

def changedAt
  @changedAt
end

#changedByObject

Returns the value of attribute changedBy.



18
19
20
# File 'lib/keytechKit/elements/element.rb', line 18

def changedBy
  @changedBy
end

#changedByLongObject

Returns the value of attribute changedByLong.



17
18
19
# File 'lib/keytechKit/elements/element.rb', line 17

def changedByLong
  @changedByLong
end

#classDisplayNameObject

Returns the value of attribute classDisplayName.



23
24
25
# File 'lib/keytechKit/elements/element.rb', line 23

def classDisplayName
  @classDisplayName
end

#createdAtObject

Returns the value of attribute createdAt.



14
15
16
# File 'lib/keytechKit/elements/element.rb', line 14

def createdAt
  @createdAt
end

#createdByObject

Returns the value of attribute createdBy.



13
14
15
# File 'lib/keytechKit/elements/element.rb', line 13

def createdBy
  @createdBy
end

#createdByLongObject

Returns the value of attribute createdByLong.



12
13
14
# File 'lib/keytechKit/elements/element.rb', line 12

def createdByLong
  @createdByLong
end

#descriptionObject

Returns the value of attribute description.



26
27
28
# File 'lib/keytechKit/elements/element.rb', line 26

def description
  @description
end

#displaynameObject

localized DisplayName



20
21
22
# File 'lib/keytechKit/elements/element.rb', line 20

def displayname
  @displayname
end

#hasVersionsObject

Returns the value of attribute hasVersions.



22
23
24
# File 'lib/keytechKit/elements/element.rb', line 22

def hasVersions
  @hasVersions
end

#keyObject

unique key of this element



6
7
8
# File 'lib/keytechKit/elements/element.rb', line 6

def key
  @key
end

#keyValueListObject

a array of value: pairs



10
11
12
# File 'lib/keytechKit/elements/element.rb', line 10

def keyValueList
  @keyValueList
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/keytechKit/elements/element.rb', line 7

def name
  @name
end

#statusObject

Returns the value of attribute status.



24
25
26
# File 'lib/keytechKit/elements/element.rb', line 24

def status
  @status
end

#thumbnailHintObject

Returns the value of attribute thumbnailHint.



21
22
23
# File 'lib/keytechKit/elements/element.rb', line 21

def thumbnailHint
  @thumbnailHint
end

#versionObject

Returns the value of attribute version.



25
26
27
# File 'lib/keytechKit/elements/element.rb', line 25

def version
  @version
end

Instance Method Details

#keytechKeyValueObjectObject

This is keytech - Style: key and value in different elements- No easy parsable hash! Sorry it was me. I was young and needed the money ;-)

{
 "Key": "au_do__categorylocalized",
 "Value": "Blaue Kategorie"

}



70
71
72
73
74
75
76
# File 'lib/keytechKit/elements/element.rb', line 70

def keytechKeyValueObject
  arrayOfKeyValuePairs = []
  keyValueList.each do |key, value|
    arrayOfKeyValuePairs.push ({ Key: key, Value: value })
  end
  arrayOfKeyValuePairs
end

#to_hashObject



59
60
61
# File 'lib/keytechKit/elements/element.rb', line 59

def to_hash
  { Key: key, Name: name, keyValueList: keytechKeyValueObject }
end