lib/scope.rb in expressive-0.0.16 vs lib/scope.rb in expressive-0.0.17

- old
+ new

@@ -76,10 +76,20 @@ syntax('set') do |scope, cells| scope[cells.first.text_value] = cells[1].eval(scope) end + syntax('$append') do |scope, cells| + scope[cells.first.text_value] = [] if scope[cells.first.text_value].nil? + addition = cells[1].eval(scope) + if addition.is_a?(Array) + scope[cells.first.text_value] = scope[cells.first.text_value] | addition + else + scope[cells.first.text_value] << addition + end + end + syntax('lookup') do |scope, cells| lookup_result = scope.lookups[cells.first.text_value] if lookup_result key = cells[1].text_value[1..-2] if lookup_result.is_a?(Hash) @@ -112,9 +122,10 @@ values = date.split('/').map(&:to_i).reverse Date.new(values[0], values[1], values[2]).to_time.utc end end + define('$id') {|*args| args.first.id } define('+') {|a,b| a.to_f + b.to_f } define('-') {|a,b| a.to_f - b.to_f } define('*') {|a,b| a.to_f * b.to_f } define('/') {|a,b| a.to_f / b.to_f } define('=') {|a,b| a == b }