Sha256: 04e867a8cd0ae59eeb72665df0d2b80918a091bbc6388a11642b0a2ce463ced6
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
# TODO: Tests module Slate class Target def self.build(metric, &block) target = new(metric) yield target if block_given? target end def initialize(metric) @metric = metric @functions = [] end def to_s target = @metric @functions.each do |function| if function.is_a? Symbol target = %Q{#{function}(#{target})} else args = arguments(function.last).join(",") target = %Q{#{function.first}(#{target},#{args})} end end target end def add_function(*function) if function.size > 1 arguments = function[1..-1] @functions << [function.first.to_sym, arguments] else @functions << function.first.to_sym end to_s end private def arguments(args=[]) args.map do |arg| if arg.is_a?(Numeric) arg.to_s elsif arg.is_a? Slate::Target arg.to_s else %Q{"#{arg}"} end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
slate-1.1.2 | lib/slate/target.rb |
slate-1.1.1 | lib/slate/target.rb |
slate-1.1.0 | lib/slate/target.rb |