Sha256: 207a1c2167ab01d8eb65729b1f3189fcb4b9f36234cfc2962d4cfaeb81ed9696

Contents?: true

Size: 503 Bytes

Versions: 3

Compression:

Stored size: 503 Bytes

Contents

require "parsable/version"
require 'parsable/parser'
require 'parsable/context'
require 'parsable/parsed_item'

module Parsable
  
  def self.crunch args={}
    original      = args.fetch(:string).to_s
    parsed_parts  = Parsable::Parser.new(args).parse
    context       = args[:context] || Parsable::Context.new

    crunched = original.dup

    parsed_parts.each do |item|
      crunched.gsub!("{{#{item.original}}}", context.read(item.object, item.attribute).to_s)
    end

    crunched
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
parsable-0.1.4 lib/parsable.rb
parsable-0.1.3 lib/parsable.rb
parsable-0.1.2 lib/parsable.rb