Class: Dnf::BooleanExpression

Inherits:
Object
  • Object
show all
Defined in:
lib/dnf/boolean_expression.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  variable_regex: /\w+/,
  not_symbol: '!',
  and_symbol: '&',
  or_symbol: '|'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression, custom_config = {}) ⇒ BooleanExpression

Returns a new instance of BooleanExpression.



12
13
14
15
# File 'lib/dnf/boolean_expression.rb', line 12

def initialize(expression, custom_config = {})
  @expression = expression
  @config = DEFAULT_CONFIG.merge(custom_config)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/dnf/boolean_expression.rb', line 3

def config
  @config
end

#expressionObject (readonly)

Returns the value of attribute expression.



3
4
5
# File 'lib/dnf/boolean_expression.rb', line 3

def expression
  @expression
end

Instance Method Details

#to_dnfObject



17
18
19
20
21
# File 'lib/dnf/boolean_expression.rb', line 17

def to_dnf
  expr = parse(expression)
  dnf = convert_to_dnf(expr)
  dnf_to_string(dnf)
end