Class: Factbase::Spy

Inherits:
Object
  • Object
show all
Defined in:
lib/factbase/spy.rb

Overview

Spy.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Defined Under Namespace

Classes: SpyFact

Instance Method Summary collapse

Constructor Details

#initialize(fb, key) ⇒ Spy

Returns a new instance of Spy.



30
31
32
33
34
# File 'lib/factbase/spy.rb', line 30

def initialize(fb, key)
  @fb = fb
  @key = key
  @caught = []
end

Instance Method Details

#caught_keysObject



36
37
38
# File 'lib/factbase/spy.rb', line 36

def caught_keys
  @caught
end

#exportObject



49
50
51
# File 'lib/factbase/spy.rb', line 49

def export
  @fb.export
end

#import(data) ⇒ Object



53
54
55
# File 'lib/factbase/spy.rb', line 53

def import(data)
  @fb.import(data)
end

#insertObject



45
46
47
# File 'lib/factbase/spy.rb', line 45

def insert
  SpyFact.new(@fb.insert, @key, @caught)
end

#query(expr) ⇒ Object



40
41
42
43
# File 'lib/factbase/spy.rb', line 40

def query(expr)
  scan(Factbase::Syntax.new(expr).to_term)
  @fb.query(expr)
end

#to_json(opt = nil) ⇒ Object



57
58
59
# File 'lib/factbase/spy.rb', line 57

def to_json(opt = nil)
  @fb.to_json(opt)
end