Class: Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/pkm_level2_converter/pools.rb

Overview

Generische Pool-Klasse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_node, type) ⇒ Pool

Returns a new instance of Pool.



14
15
16
17
18
19
# File 'lib/pkm_level2_converter/pools.rb', line 14

def initialize(xml_node, type)
  @type = type
  @key = xml_node['key'].to_i
  children = xml_node.children
  @items = children.map.with_index { |parameter, index| type.new(parameter, @key, index) }
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.



21
22
23
# File 'lib/pkm_level2_converter/pools.rb', line 21

def items
  @items
end

#keyObject (readonly)

Returns the value of attribute key.



21
22
23
# File 'lib/pkm_level2_converter/pools.rb', line 21

def key
  @key
end

Class Method Details

.parse_pool(xml_node, path_of_pool, type_of_pool) ⇒ Object

MOVED TO PKM-Class



8
9
10
11
12
# File 'lib/pkm_level2_converter/pools.rb', line 8

def self.parse_pool(xml_node, path_of_pool, type_of_pool)
  # pool = @@pools[poolSymbol]
  node = xml_node.at_xpath(path_of_pool)
  type_of_pool.new(node)
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/pkm_level2_converter/pools.rb', line 27

def empty?
  (@items.nil? || @items.empty?)
end

#get_by_reference(key) ⇒ Object



23
24
25
# File 'lib/pkm_level2_converter/pools.rb', line 23

def get_by_reference(key)
  @items.find { |item| item.key == key }
end

#lengthObject



31
32
33
# File 'lib/pkm_level2_converter/pools.rb', line 31

def length
  @items.length
end