Class: ConceptQL::Nodifier
- Inherits:
-
Object
- Object
- ConceptQL::Nodifier
- Defined in:
- lib/conceptql/nodifier.rb
Instance Attribute Summary collapse
-
#algorithm_fetcher ⇒ Object
readonly
Returns the value of attribute algorithm_fetcher.
-
#data_model ⇒ Object
readonly
Returns the value of attribute data_model.
-
#database_type ⇒ Object
readonly
Returns the value of attribute database_type.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
- #create(operator, *values) ⇒ Object
-
#initialize(opts = {}) ⇒ Nodifier
constructor
A new instance of Nodifier.
- #to_metadata(opts = {}) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Nodifier
Returns a new instance of Nodifier.
7 8 9 10 11 12 13 14 |
# File 'lib/conceptql/nodifier.rb', line 7 def initialize(opts={}) @scope = opts[:scope] || Scope.new(opts) @data_model = opts[:data_model] || :omopv4 @database_type = opts[:database_type] || :impala @algorithm_fetcher = opts[:algorithm_fetcher] || (proc do |alg| nil end) end |
Instance Attribute Details
#algorithm_fetcher ⇒ Object (readonly)
Returns the value of attribute algorithm_fetcher.
5 6 7 |
# File 'lib/conceptql/nodifier.rb', line 5 def algorithm_fetcher @algorithm_fetcher end |
#data_model ⇒ Object (readonly)
Returns the value of attribute data_model.
5 6 7 |
# File 'lib/conceptql/nodifier.rb', line 5 def data_model @data_model end |
#database_type ⇒ Object (readonly)
Returns the value of attribute database_type.
5 6 7 |
# File 'lib/conceptql/nodifier.rb', line 5 def database_type @database_type end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
5 6 7 |
# File 'lib/conceptql/nodifier.rb', line 5 def scope @scope end |
Instance Method Details
#create(operator, *values) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/conceptql/nodifier.rb', line 16 def create(operator, *values) if operator.to_s == 'algorithm' statement, desc = algorithm_fetcher.call(values.first) if statement create(*statement) else invalid_op(operator, values, "invalid algorithm", values.first) end elsif klass = operators[operator.to_s] klass.new(self, *values) else invalid_op(operator, values, "invalid operator", operator) end end |
#to_metadata(opts = {}) ⇒ Object
31 32 33 |
# File 'lib/conceptql/nodifier.rb', line 31 def (opts = {}) Hash[operators.map { |k, v| [k, v.(k, opts)]}.select { |k, v| !v[:categories].empty? }.sort_by { |k, v| v[:name] }] end |