Class: Tricle::Metric
Instance Attribute Summary collapse
Instance Method Summary
collapse
#periods_ago, #range_average, #range_values
Constructor Details
#initialize(opts = {}) ⇒ Metric
Returns a new instance of Metric.
12
13
14
15
|
# File 'lib/tricle/metric.rb', line 12
def initialize(opts = {})
@now = Tricle::Time.new(opts[:now])
@options = opts
end
|
Instance Attribute Details
#now ⇒ Object
Returns the value of attribute now.
10
11
12
|
# File 'lib/tricle/metric.rb', line 10
def now
@now
end
|
#options ⇒ Object
Returns the value of attribute options.
10
11
12
|
# File 'lib/tricle/metric.rb', line 10
def options
@options
end
|
Instance Method Details
#better ⇒ Object
29
30
31
|
# File 'lib/tricle/metric.rb', line 29
def better
options[:better] || :higher
end
|
#items_for_range(start_at, end_at) ⇒ Object
41
42
43
|
# File 'lib/tricle/metric.rb', line 41
def items_for_range(start_at, end_at)
raise Tricle::AbstractMethodError.new
end
|
#size_for_range(start_at, end_at) ⇒ Object
37
38
39
|
# File 'lib/tricle/metric.rb', line 37
def size_for_range(start_at, end_at)
self.items_for_range(start_at, end_at).size
end
|
#sparkline? ⇒ Boolean
17
18
19
20
21
22
23
|
# File 'lib/tricle/metric.rb', line 17
def sparkline?
if options.key?(:sparkline)
options[:sparkline]
else
Tricle.configuration.sparklines
end
end
|
#title ⇒ Object
33
34
35
|
# File 'lib/tricle/metric.rb', line 33
def title
options[:title] || self.class.name.titleize
end
|
#total? ⇒ Boolean
45
46
47
|
# File 'lib/tricle/metric.rb', line 45
def total?
self.respond_to?(:total)
end
|
#unit ⇒ Object
25
26
27
|
# File 'lib/tricle/metric.rb', line 25
def unit
options[:unit]
end
|