Class: ConceptQL::Nodifier
- Inherits:
-
Object
- Object
- ConceptQL::Nodifier
- Defined in:
- lib/conceptql/nodifier.rb
Instance Attribute Summary collapse
-
#operators ⇒ Object
readonly
Returns the value of attribute operators.
Instance Method Summary collapse
- #create(scope, operator, *values) ⇒ Object
-
#initialize ⇒ Nodifier
constructor
A new instance of Nodifier.
- #to_metadata ⇒ Object
Constructor Details
#initialize ⇒ Nodifier
Returns a new instance of Nodifier.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/conceptql/nodifier.rb', line 9 def initialize @operators = {} dir = Pathname.new(__FILE__).dirname() dir.chdir do Pathname.glob("operators/*.rb").each do |file| require_relative file operator = file.basename('.*').to_s.to_sym klass = Object.const_get("conceptQL/operators/#{operator}".modulize) @operators[operator] = klass end end end |
Instance Attribute Details
#operators ⇒ Object (readonly)
Returns the value of attribute operators.
7 8 9 |
# File 'lib/conceptql/nodifier.rb', line 7 def operators @operators end |
Instance Method Details
#create(scope, operator, *values) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/conceptql/nodifier.rb', line 22 def create(scope, operator, *values) operator = operator.to_sym if operators[operator].nil? raise "Can't find operator for '#{operator}' in #{operators.keys.sort}" end operator = operators[operator].new(*values) operator.scope = scope operator end |
#to_metadata ⇒ Object
32 33 34 |
# File 'lib/conceptql/nodifier.rb', line 32 def Hash[operators.map { |k, v| [k, v.]}.select { |k, v| v[:desc] }] end |