Class: ForemanStatistics::Statistics::Base
- Inherits:
-
Object
- Object
- ForemanStatistics::Statistics::Base
- Defined in:
- app/services/foreman_statistics/statistics/base.rb
Direct Known Subclasses
CountFacts, CountHosts, CountNumericalFactPair, CountPuppetClasses
Instance Attribute Summary collapse
-
#count_by ⇒ Object
readonly
Returns the value of attribute count_by.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #calculate ⇒ Object
- #id ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #metadata ⇒ Object
- #search ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
6 7 8 9 10 11 12 13 14 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 6 def initialize( = {}) @id = [:id] @title = [:title] @search = [:search] @count_by = [:count_by] @organization_id = [:organization_id] @location_id = [:location_id] @url = [:url] || build_url end |
Instance Attribute Details
#count_by ⇒ Object (readonly)
Returns the value of attribute count_by.
4 5 6 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 4 def count_by @count_by end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
4 5 6 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 4 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 4 def url @url end |
Instance Method Details
#calculate ⇒ Object
16 17 18 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 16 def calculate raise NotImplementedError, "Method 'calculate' method needs to be implemented" end |
#id ⇒ Object
20 21 22 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 20 def id @id || count_by.to_s end |
#metadata ⇒ Object
28 29 30 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 28 def { :id => id, :title => title, :url => url, :search => search } end |
#search ⇒ Object
24 25 26 |
# File 'app/services/foreman_statistics/statistics/base.rb', line 24 def search Rails.application.routes.url_helpers.hosts_path(:search => @search) end |