Class: DbdDataEngine::ContextsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DbdDataEngine::ContextsController
- Defined in:
- app/controllers/dbd_data_engine/contexts_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/dbd_data_engine/contexts_controller.rb', line 15 def create graph = Dbd::Graph.new @context = Dbd::Context.new() [params[:predicate], params[:object]].transpose.each do |predicate, object| context_fact = Dbd::ContextFact.new(predicate: predicate, object_type: 's', object: object) @context << context_fact end graph << @context # TODO move this to graph new_data = graph.to_CSV File.open(filename, 'a') do |f| f.syswrite new_data end end |
#index ⇒ Object
5 6 7 8 9 |
# File 'app/controllers/dbd_data_engine/contexts_controller.rb', line 5 def index graph = Dbd::Graph.new graph = graph.from_unsorted_CSV_file(filename) @contexts = graph.contexts end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/dbd_data_engine/contexts_controller.rb', line 11 def new @predicates = Context.predicates end |