Class: Factbase::Syntax

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

Overview

Syntax.

This is an internal class, it is not supposed to be instantiated directly.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2024 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(query) ⇒ Syntax

Ctor.

Parameters:

  • query (String)

    The query, for example “(eq id 42)”



38
39
40
# File 'lib/factbase/syntax.rb', line 38

def initialize(query)
  @query = query
end

Instance Method Details

#to_termTerm

Convert it to a term.

Returns:

  • (Term)

    The term detected



44
45
46
47
48
49
50
# File 'lib/factbase/syntax.rb', line 44

def to_term
  build.simplify
rescue StandardError => e
  err = "#{e.message} in #{@query}"
  err = "#{err}, tokens: #{@tokens}" unless @tokens.nil?
  raise err
end