Class: Desmoservice::Get

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGet

Returns a new instance of Get.



4
5
# File 'lib/get.rb', line 4

def initialize
end

Class Method Details

.families(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/get.rb', line 7

def self.families(desmoservice_conf, get_params, http: nil, log_handler: nil)
  options = get_params.to_h('familles')
  uri = desmoservice_conf.build_json_uri(options)
  if http.nil?
    json_string = Net::HTTP.get(uri)
  else
    request = Net::HTTP::Get.new(uri)
    response = http.request(request)
    json_string = response.body
  end
  families = Families.new()
  families.parse_json(json_string)
  if not log_handler.nil?
    log_handler.add_log_message(uri.to_s)
    log_handler.add_log_message(json_string.force_encoding("UTF-8"))
    log_handler.new_line()
  end
  return families
end

.terms(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/get.rb', line 67

def self.terms(desmoservice_conf, get_params, http: nil, log_handler: nil)
  options = get_params.to_h('terms')
  uri = desmoservice_conf.build_json_uri(options)
  if http.nil?
    json_string = Net::HTTP.get(uri)
  else
    request = Net::HTTP::Get.new(uri)
    response = http.request(request)
    json_string = response.body
  end
  terms = Terms.new()
  terms.parse_json(json_string)
  if not log_handler.nil?
    log_handler.add_log_message(uri.to_s)
    log_handler.add_log_message(json_string.force_encoding("UTF-8"))
    log_handler.new_line()
  end
  return terms
end

.ventilation(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/get.rb', line 27

def self.ventilation(desmoservice_conf, get_params, http: nil, log_handler: nil)
  options = get_params.to_h('ventilation')
  uri = desmoservice_conf.build_json_uri(options)
  if http.nil?
    json_string = Net::HTTP.get(uri)
  else
    request = Net::HTTP::Get.new(uri)
    response = http.request(request)
    json_string = response.body
  end
  ventilation = Ventilation.new()
  ventilation.parse_json(json_string)
  if not log_handler.nil?
    log_handler.add_log_message(uri.to_s)
    log_handler.add_log_message(json_string.force_encoding("UTF-8"))
    log_handler.new_line()
  end
  return ventilation
end

.word_distribution(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/get.rb', line 47

def self.word_distribution(desmoservice_conf, get_params, http: nil, log_handler: nil)
  options = get_params.to_h('lexiedistribution')
  uri = desmoservice_conf.build_json_uri(options)
  if http.nil?
    json_string = Net::HTTP.get(uri)
  else
    request = Net::HTTP::Get.new(uri)
    response = http.request(request)
    json_string = response.body
  end
  word_distribution = WordDistribution.new()
  word_distribution.parse_json(json_string)
  if not log_handler.nil?
    log_handler.add_log_message(uri.to_s)
    log_handler.add_log_message(json_string.force_encoding("UTF-8"))
    log_handler.new_line()
  end
  return word_distribution
end