Class: ForemanStatistics::Statistics::Base

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_statistics/statistics/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @id = options[:id]
  @title = options[:title]
  @search = options[:search]
  @count_by = options[:count_by]
  @organization_id = options[:organization_id]
  @location_id = options[:location_id]
  @url = options[:url] || build_url
end

Instance Attribute Details

#count_byObject (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

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'app/services/foreman_statistics/statistics/base.rb', line 4

def title
  @title
end

#urlObject (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

#calculateObject

Raises:

  • (NotImplementedError)


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

#idObject



20
21
22
# File 'app/services/foreman_statistics/statistics/base.rb', line 20

def id
  @id || count_by.to_s
end

#metadataObject



28
29
30
# File 'app/services/foreman_statistics/statistics/base.rb', line 28

def 
  { :id => id, :title => title, :url => url, :search => search }
end

#searchObject



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