Sha256: 1bce7c3fa74cd28b3425e19ae99f0ee38de85303e98075c4592c94bf2b872123
Contents?: true
Size: 940 Bytes
Versions: 4
Compression:
Stored size: 940 Bytes
Contents
require "celsius" class Celsius::Transformation # # class methods # class << self attr_accessor :steps end # since a transformation can have many steps, writing a "require" for each is tedious def self.require_directory(directory) Dir.glob("#{File.expand_path(directory)}/*.rb").each do |filename| require filename end end # convenience wrapper for @steps setter to enhance readability def self.sequence(value) self.steps = value end # # instance methods # attr_accessor :source attr_accessor :target def apply(options = {}) if (@source = options[:source] ||= options[:to]).nil? raise ArgumentError, "No source given to apply transformation to!" end @target = options[:target] self.class.steps.flatten.each do |step| if step.is_a?(Class) step.new(self).call else step.call(self) end end return @target end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
celsius-0.4.3 | lib/celsius/transformation.rb |
celsius-0.4.2 | lib/celsius/transformation.rb |
celsius-0.4.1 | lib/celsius/transformation.rb |
celsius-0.4.0 | lib/celsius/transformation.rb |