Permalink
Browse files

Merge pull request #9 from splattael/refactor-format

Simplify `Sparkline#format`
  • Loading branch information...
2 parents 067bcb4 + 7f6ec7f commit cd37e8871789a2c264bd0ed0d48c120cadf1d3c1 @rrrene committed Feb 3, 2014
Showing with 3 additions and 9 deletions.
  1. +3 −9 lib/sparkr/sparkline.rb
View
@@ -46,16 +46,10 @@ def initialize(_numbers)
# # => "▁█" (colored, which you can't see)
#
# @return [Sparkline] itself
- def format(&block)
- new_ticks = []
- @ticks.each_with_index do |tick, index|
- if block.arity == 2
- new_ticks << yield(tick, @original_numbers[index])
- elsif block.arity == 3
- new_ticks << yield(tick, @original_numbers[index], index)
- end
+ def format
+ @ticks = @ticks.map.with_index do |tick, index|
+ yield tick, @original_numbers[index], index
end
- @ticks = new_ticks
self
end

0 comments on commit cd37e88

Please sign in to comment.