Class: Desmoservice::Terms

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

Instance Method Summary collapse

Constructor Details

#initializeTerms

Returns a new instance of Terms.



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

def initialize()
  @array = Array.new
end

Instance Method Details

#[](index) ⇒ Object



26
27
28
# File 'lib/terms.rb', line 26

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

#eachObject



16
17
18
19
20
# File 'lib/terms.rb', line 16

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

#lengthObject



22
23
24
# File 'lib/terms.rb', line 22

def length
  return @array.length
end

#parse_json(json_string) ⇒ Object



9
10
11
12
13
14
# File 'lib/terms.rb', line 9

def parse_json(json_string)
  data = JSON.parse(json_string)
  if data.has_key?('terms')
    data['terms'].each {|v| @array << Term.new(v)}
  end
end