lib/parsable.rb in parsable-0.0.3 vs lib/parsable.rb in parsable-0.1.0
- old
+ new
@@ -1,10 +1,20 @@
require "parsable/version"
require 'parsable/parser'
+require 'parsable/context'
module Parsable
def self.crunch args={}
- Parsable::Parser.new(args).crunch
+ original = args.fetch(:string).to_s
+ parsed_parts = Parsable::Parser.new(args).parse
+
+ crunched = original.dup
+
+ parsed_parts.each do |item|
+ crunched.gsub!("{{#{item[:original]}}}", "#{item[:lambda].call}")
+ end
+
+ crunched
end
end