lib/scope.rb in expressive-0.0.25 vs lib/scope.rb in expressive-0.0.26

- old
+ new

@@ -86,10 +86,21 @@ else scope[cells.first.text_value] << addition end end + syntax('$hash') do |scope, cells| + puts "$hash..." + hash = {} + cells.each do |cell| + key = cell.elements[1].elements[0].elements[1].text_value + value = cell.elements[1].elements[1].elements[1].instance_eval{eval(scope)} + puts value.class + hash[key] = value + end + hash + end syntax('$lookup') {|scope, cells| perform_lookup(scope, cells)} syntax('lookup') {|scope, cells| perform_lookup(scope, cells)} syntax('post') do |scope, cells| @@ -109,9 +120,17 @@ Date.today.to_time.utc else date = cells.first.text_value.gsub(/[\)\(]/, '') values = date.split('/').map(&:to_i).reverse Date.new(values[0], values[1], values[2]).to_time.utc + end + end + syntax('datetime') do |scope, cells| + if cells.empty? + DateTime.now + else + date = cells.first.text_value.gsub(/[\)\(]/, '') + DateTime.parse(date) end end define('$id') {|*args| args.first.id } define('+') {|a,b| a.to_f + b.to_f }