mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-08 10:18:50 +01:00
Extract chart value object
This simplifies the views (slightly).
This commit is contained in:
parent
8b0f3e986a
commit
0aa6ea183b
7 changed files with 65 additions and 41 deletions
18
app/models/stats/chart.rb
Normal file
18
app/models/stats/chart.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module Stats
|
||||
|
||||
class Chart
|
||||
|
||||
attr_reader :action, :height, :width
|
||||
def initialize(action, dimensions = {})
|
||||
@action = action
|
||||
@height = dimensions.fetch(:height) { 250 }
|
||||
@width = dimensions.fetch(:width) { 460 }
|
||||
end
|
||||
|
||||
def dimensions
|
||||
"#{width}x#{height}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue