Class: Sparkplug::Cachers::Abstract
- Inherits:
-
Object
- Object
- Sparkplug::Cachers::Abstract
- Defined in:
- lib/sparkplug/cachers/abstract.rb
Overview
Reads sparkline data from CSV files. Only the first line of numbers are read. Requests for “/sparks/stats.csv” will pass a data_path of “stats.csv”
Direct Known Subclasses
Instance Attribute Summary collapse
-
#png_path ⇒ Object
Returns the value of attribute png_path.
Instance Method Summary collapse
- #create_sparklines(data, options) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize ⇒ Abstract
constructor
A new instance of Abstract.
- #save(data, options) ⇒ Object
- #serve(app, headers = {}) ⇒ Object
-
#set(png_path) ⇒ Object
Setting the png_path returns a duplicate of this object that has any custom instance variables (configuration settings, for example).
- #size ⇒ Object
- #stream ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize ⇒ Abstract
Returns a new instance of Abstract.
10 11 12 |
# File 'lib/sparkplug/cachers/abstract.rb', line 10 def initialize @size, @updated_at = nil end |
Instance Attribute Details
#png_path ⇒ Object
Returns the value of attribute png_path.
8 9 10 |
# File 'lib/sparkplug/cachers/abstract.rb', line 8 def png_path @png_path end |
Instance Method Details
#create_sparklines(data, options) ⇒ Object
34 35 36 |
# File 'lib/sparkplug/cachers/abstract.rb', line 34 def create_sparklines(data, ) Spark.plot(data, ) end |
#exists? ⇒ Boolean
26 27 28 |
# File 'lib/sparkplug/cachers/abstract.rb', line 26 def exists? raise NotImplementedError end |
#save(data, options) ⇒ Object
47 48 49 |
# File 'lib/sparkplug/cachers/abstract.rb', line 47 def save(data, ) raise NotImplementedError end |
#serve(app, headers = {}) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/sparkplug/cachers/abstract.rb', line 38 def serve(app, headers = {}) headers = { "Last-Modified" => updated_at.rfc822, "Content-Type" => "image/png", "Content-Length" => size.to_s }.update(headers) [200, headers, app] end |
#set(png_path) ⇒ Object
Setting the png_path returns a duplicate of this object that has any custom instance variables (configuration settings, for example).
16 17 18 19 20 |
# File 'lib/sparkplug/cachers/abstract.rb', line 16 def set(png_path) cacher = dup cacher.png_path = png_path cacher end |
#size ⇒ Object
22 23 24 |
# File 'lib/sparkplug/cachers/abstract.rb', line 22 def size raise NotImplementedError end |
#stream ⇒ Object
51 52 53 |
# File 'lib/sparkplug/cachers/abstract.rb', line 51 def stream raise NotImplementedError end |
#updated_at ⇒ Object
30 31 32 |
# File 'lib/sparkplug/cachers/abstract.rb', line 30 def updated_at raise NotImplementedError end |