Class: Desmoservice::Families

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/families.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFamilies

Returns a new instance of Families.



7
8
9
10
# File 'lib/families.rb', line 7

def initialize()
  @array = Array.new
  @orphan_members = Array.new
end

Instance Attribute Details

#orphan_termsObject (readonly)

Returns the value of attribute orphan_terms.



5
6
7
# File 'lib/families.rb', line 5

def orphan_terms
  @orphan_terms
end

Instance Method Details

#[](index) ⇒ Object



35
36
37
# File 'lib/families.rb', line 35

def [](index)
  return @array[index]
end

#eachObject



25
26
27
28
29
# File 'lib/families.rb', line 25

def each
  @array.each do |v|
    yield(v)
  end
end

#lengthObject



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

def length
  return @array.length
end

#parse_json(json_string) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/families.rb', line 12

def parse_json(json_string)
  data = JSON.parse(json_string)
  if data.has_key?('familles')
    familles = data['familles']
    if familles.has_key?('familleArray')
      familles['familleArray'].each {|v| @array << Family.new(v)}
    end
    if familles.has_key?('sansfamille')
      familles['descripteurArray'].each {|v| @orphan_terms << Term.new(v)}
    end
  end
end