Sha256: 21fd72ed44f17247b27755a207956aeca23948cf80a384c52f170ec81eb2fb16

Contents?: true

Size: 645 Bytes

Versions: 20

Compression:

Stored size: 645 Bytes

Contents

module Distil
  
  class Interpolated
    
    def initialize(value, owner=nil)
      @value=value
      @owner=owner
    end

    def self.from_options(set, owner)
      self.new(set, owner)
    end
    
    def self.value_of(value, owner)
      return value if !owner
      
      value.gsub(/\$\((\w+)\)/) { |match|
        v= case
        when owner.respond_to?($1)
          owner.send $1
        when owner.is_a?(Configurable)
          owner.get_option($1)
        end
        
        v || "$(#{$1})"
      }
    end
    
    def value_of(owner=nil)
      owner||=@owner
      self.class.value_of(@value, owner)
    end
    
  end
  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
distil-0.13.6 lib/distil/configurable/interpolated.rb
distil-0.13.5 lib/distil/configurable/interpolated.rb
distil-0.13.4 lib/distil/configurable/interpolated.rb
distil-0.13.3 lib/distil/configurable/interpolated.rb
distil-0.13.2 lib/distil/configurable/interpolated.rb
distil-0.13.1 lib/distil/configurable/interpolated.rb
distil-0.13.0 lib/distil/configurable/interpolated.rb
distil-0.12.6 lib/distil/configurable/interpolated.rb
distil-0.12.4 lib/distil/configurable/interpolated.rb
distil-0.12.3 lib/distil/configurable/interpolated.rb
distil-0.12.2 lib/distil/configurable/interpolated.rb
distil-0.12.1 lib/distil/configurable/interpolated.rb
distil-0.12.0 lib/distil/configurable/interpolated.rb
distil-0.11.8 lib/distil/configurable/interpolated.rb
distil-0.11.6 lib/distil/configurable/interpolated.rb
distil-0.11.5 lib/distil/configurable/interpolated.rb
distil-0.11.4 lib/distil/configurable/interpolated.rb
distil-0.11.3 lib/distil/configurable/interpolated.rb
distil-0.11.1 lib/distil/configurable/interpolated.rb
distil-0.11.0 lib/distil/configurable/interpolated.rb