Class: Extract::Expression
- Inherits:
-
Object
- Object
- Extract::Expression
- Defined in:
- lib/src/extract/expression.rb
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(expression, hash) ⇒ Expression
constructor
A new instance of Expression.
Constructor Details
#initialize(expression, hash) ⇒ Expression
Returns a new instance of Expression.
5 6 7 8 |
# File 'lib/src/extract/expression.rb', line 5 def initialize(expression, hash) @expression = expression @hash = hash end |
Instance Method Details
#evaluate ⇒ Object
10 11 12 13 14 15 |
# File 'lib/src/extract/expression.rb', line 10 def evaluate keys = Regexp.union(hash.keys.map(&:to_s)) condition = expression.gsub(keys, hash.stringify_keys) eval(condition) end |