class Bindgen::ConfigReader::ConditionEvaluator

Overview

Implements the condition evaluation logic of Parser.

See Parsers documentation for a description of the syntax.

You can sub-class this and pass an instance into a Parser if you want to augment its feature-set.

Defined in:

bindgen/config_reader/condition_evaluator.cr

Constant Summary

RX = /^(?:els)?if(?: +|_)(.+?)(?: +|_)(is|isnt|matches|newer_or|older_or)(?: +|_)(.*)$/

Regular expression for conditionals. Matches: [els]if VARIABLE (is|matches) VALUE. Instead of a space, an underscore may be used instead.

Constructors

Instance Method Summary

Constructor Detail

def self.new(variables : Hash(String, String)) #

[View source]

Instance Method Detail

def conditional?(text : String) : Bool #

Returns true if the text looks like a condition. This is used to feed all keys in a mapping into.


[View source]
def evaluate(condition_text : String, state : ConditionState) : Tuple(Bool, ConditionState) #

Evaluates condition_text.


[View source]
def read_verb(text : String) : Verb | Nil #

Reads the conditional verb from text, if any.


[View source]
def variables : Hash(String, String) #

Accessible variables


[View source]