Sha256: c749a6aeacb95fac50ea2f8996d843f1a68ef92a2dcfd5fe58be004fa0e43e12
Contents?: true
Size: 781 Bytes
Versions: 2
Compression:
Stored size: 781 Bytes
Contents
require_relative '../generator' module Dagger module Generate # Generate a value for a +string+ rule. # # _default.key: # - string: "format string" # - string: # - "format string" # - ... class String < Dagger::Generator def process(strings) enumerable(strings).each do |fmtstr| result = format_string(fmtstr, dictionary) yield result unless result.nil? end end private # Format a +string+ with values from a +dictionary+ # # :call-seq: # format_string(string, dictionary) def format_string(string, dictionary) Kernel.format(string, Hash.new { |_, key| dictionary[key] }) rescue KeyError nil end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ruby-dagger-0.1.1 | lib/dagger/generator/string.rb |
ruby-dagger-0.1.0 | lib/dagger/generator/string.rb |