Class: Tobias::Evaluations::Base
- Inherits:
-
Object
- Object
- Tobias::Evaluations::Base
- Defined in:
- lib/tobias/evaluations/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(database, container, options) ⇒ Base
constructor
A new instance of Base.
- #render_table(headers:, body:) ⇒ Object
- #run(&block) ⇒ Object
- #run_each(query) ⇒ Object
- #to_markdown(results) ⇒ Object
Constructor Details
#initialize(database, container, options) ⇒ Base
Returns a new instance of Base.
26 27 28 29 30 |
# File 'lib/tobias/evaluations/base.rb', line 26 def initialize(database, container, ) @database = database @container = container = end |
Instance Attribute Details
#container ⇒ Object (readonly)
Returns the value of attribute container.
24 25 26 |
# File 'lib/tobias/evaluations/base.rb', line 24 def container @container end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
24 25 26 |
# File 'lib/tobias/evaluations/base.rb', line 24 def database @database end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/tobias/evaluations/base.rb', line 24 def end |
Instance Method Details
#render_table(headers:, body:) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/tobias/evaluations/base.rb', line 54 def render_table(headers:, body:) table = TTY::Table.new(header: headers) body.each do |row| table << row end table.render_with(MarkdownTableBorder) end |
#run(&block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tobias/evaluations/base.rb', line 32 def run(&block) results = Concurrent::Array.new container.run_setup container.queries.each do |name, query| result = run_each(name, query) results << result if result end to_markdown(results) ensure container.run_teardown end |
#run_each(query) ⇒ Object
46 47 48 |
# File 'lib/tobias/evaluations/base.rb', line 46 def run_each(query) raise NotImplementedError end |
#to_markdown(results) ⇒ Object
50 51 52 |
# File 'lib/tobias/evaluations/base.rb', line 50 def to_markdown(results) raise NotImplementedError end |