Class: Slate::Target
- Inherits:
-
Object
- Object
- Slate::Target
- Defined in:
- lib/slate/target.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_function(*function) ⇒ Object
-
#initialize(metric) ⇒ Target
constructor
A new instance of Target.
- #to_s ⇒ Object
Constructor Details
#initialize(metric) ⇒ Target
Returns a new instance of Target.
10 11 12 13 |
# File 'lib/slate/target.rb', line 10 def initialize(metric) @metric = metric @functions = [] end |
Class Method Details
.build(metric) {|target| ... } ⇒ Object
4 5 6 7 8 |
# File 'lib/slate/target.rb', line 4 def self.build(metric, &block) target = new(metric) yield target if block_given? target end |
Instance Method Details
#add_function(*function) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/slate/target.rb', line 29 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 |
#to_s ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/slate/target.rb', line 15 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 |