Class: Hyrax::Statistics::TermQuery::Result

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/statistics/term_query.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, value) ⇒ Result

Returns a new instance of Result.



44
45
46
# File 'app/services/hyrax/statistics/term_query.rb', line 44

def initialize(label, value)
  @data = { label: label, data: value }
end

Class Method Details

.build(rows) ⇒ Object

Parameters:

  • rows (Array<Array>)

    list of of tuples (label, value)



40
41
42
# File 'app/services/hyrax/statistics/term_query.rb', line 40

def self.build(rows)
  rows.map { |row| Result.new(*row) }
end

Instance Method Details

#==(other) ⇒ Object

This enables hash equivalence



57
58
59
# File 'app/services/hyrax/statistics/term_query.rb', line 57

def ==(other)
  other == @data
end

#as_json(opts) ⇒ Object

Allows us to create a Flot charts pie-graph



62
63
64
# File 'app/services/hyrax/statistics/term_query.rb', line 62

def as_json(opts)
  @data.as_json(opts)
end

#labelObject



48
49
50
# File 'app/services/hyrax/statistics/term_query.rb', line 48

def label
  @data[:label]
end

#valueObject



52
53
54
# File 'app/services/hyrax/statistics/term_query.rb', line 52

def value
  @data[:data]
end