Class: Prolego::Query
- Inherits:
-
Object
- Object
- Prolego::Query
- Defined in:
- lib/prolego.rb
Instance Method Summary collapse
- #command(predicate, args) ⇒ Object
- #epilog ⇒ Object
-
#initialize(filepath) ⇒ Query
constructor
A new instance of Query.
- #parg(arg) ⇒ Object
Constructor Details
#initialize(filepath) ⇒ Query
Returns a new instance of Query.
6 7 8 |
# File 'lib/prolego.rb', line 6 def initialize filepath @file=filepath end |
Instance Method Details
#command(predicate, args) ⇒ Object
10 11 12 |
# File 'lib/prolego.rb', line 10 def command predicate,args @output=%x[swipl -q -f '#{@file}' -g '#{parg predicate}(#{parg args}),halt'] end |
#epilog ⇒ Object
18 19 20 |
# File 'lib/prolego.rb', line 18 def epilog @output.lines.map {|x| x.slice(/.*d/).split("------").join " "} end |
#parg(arg) ⇒ Object
14 15 16 |
# File 'lib/prolego.rb', line 14 def parg arg arg.to_s.gsub /^\[|"|'|\]$/, "[" => "", "]" => "", "'" => "'\"'\"'", "\"" => "'\"'\"'" end |