Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Simplify `Sparkline#format` #9

Merged
merged 1 commit into from

2 participants

@splattael
  • No need for arity checks
  • Use Enumerable#map
@splattael splattael Simplify `Sparkline#format`
* No need for arity checks
* Use `Enumerable#map`
7f6ec7f
@rrrene rrrene merged commit cd37e88 into rrrene:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 3, 2014
  1. @splattael

    Simplify `Sparkline#format`

    splattael authored
    * No need for arity checks
    * Use `Enumerable#map`
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 9 deletions.
  1. +3 −9 lib/sparkr/sparkline.rb
View
12 lib/sparkr/sparkline.rb
@@ -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
Something went wrong with that request. Please try again.