Class: Desmoservice::Get
- Inherits:
-
Object
- Object
- Desmoservice::Get
- Defined in:
- lib/get.rb
Class Method Summary collapse
- .families(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object
- .terms(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object
- .ventilation(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object
- .word_distribution(desmoservice_conf, get_params, http: nil, log_handler: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Get
constructor
A new instance of Get.
Constructor Details
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) = get_params.to_h('familles') uri = desmoservice_conf.build_json_uri() 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.(uri.to_s) log_handler.(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) = get_params.to_h('terms') uri = desmoservice_conf.build_json_uri() 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.(uri.to_s) log_handler.(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) = get_params.to_h('ventilation') uri = desmoservice_conf.build_json_uri() 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.(uri.to_s) log_handler.(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) = get_params.to_h('lexiedistribution') uri = desmoservice_conf.build_json_uri() 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.(uri.to_s) log_handler.(json_string.force_encoding("UTF-8")) log_handler.new_line() end return word_distribution end |