Class: Tricle::Metric
Instance Attribute Summary collapse
Instance Method Summary
collapse
#days_ago, #last_week, #week_average_this_quarter, #weekly_values, #weeks_ago, #weeks_average, #yesterday
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
17
18
19
|
# File 'lib/tricle/metric.rb', line 17
def better
options[:better] || :higher
end
|
#items_for_range(start_at, end_at) ⇒ Object
29
30
31
|
# File 'lib/tricle/metric.rb', line 29
def items_for_range(start_at, end_at)
raise Tricle::AbstractMethodError.new
end
|
#size_for_range(start_at, end_at) ⇒ Object
25
26
27
|
# File 'lib/tricle/metric.rb', line 25
def size_for_range(start_at, end_at)
self.items_for_range(start_at, end_at).size
end
|
#title ⇒ Object
21
22
23
|
# File 'lib/tricle/metric.rb', line 21
def title
options[:title] || self.class.name.titleize
end
|
#total? ⇒ Boolean
33
34
35
|
# File 'lib/tricle/metric.rb', line 33
def total?
self.respond_to?(:total)
end
|