Class: ImgToScript::MK90ClientAPI::QueryHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/img_to_script/mk90_client_api/query_handler.rb

Overview

Handles query.

Instance Method Summary collapse

Instance Method Details

#call(query) ⇒ Array<String>

Handle query:

  1. validate input query;

  2. if query is correct: configure and call an ImgToScript task instance;

  3. return result of the ImgToScript::Task call.

Parameters:

  • query (Hash{ Symbol => Object }, Hash{ String => Object })

Returns:

  • (Array<String>)

    Generated BASIC script.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/img_to_script/mk90_client_api/query_handler.rb', line 21

def call(query)
  valid_query = _validate_input(query)

  task = _init_task(valid_query)

  image = _prepare_image(
    _read_image(valid_query[:image])
  )

  task.run(
    image: image,
    scr_width: ImgToScript::Languages::MK90Basic::SCR_WIDTH,
    scr_height: ImgToScript::Languages::MK90Basic::SCR_HEIGHT
  )
end