Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Sparkline#format #9

Merged
merged 1 commit into from Feb 3, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions lib/sparkr/sparkline.rb
Expand Up @@ -46,16 +46,10 @@ def initialize(_numbers)
# # => "▁█" (colored, which you can't see) # # => "▁█" (colored, which you can't see)
# #
# @return [Sparkline] itself # @return [Sparkline] itself
def format(&block) def format
new_ticks = [] @ticks = @ticks.map.with_index do |tick, index|
@ticks.each_with_index do |tick, index| yield tick, @original_numbers[index], 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
end end
@ticks = new_ticks
self self
end end


Expand Down