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.


42
43
44
# File 'app/services/hyrax/statistics/term_query.rb', line 42

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)


38
39
40
# File 'app/services/hyrax/statistics/term_query.rb', line 38

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

Instance Method Details

#==(other) ⇒ Object

This enables hash equivalence


55
56
57
# File 'app/services/hyrax/statistics/term_query.rb', line 55

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

#as_json(opts) ⇒ Object

Allows us to create a Flot charts pie-graph


60
61
62
# File 'app/services/hyrax/statistics/term_query.rb', line 60

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

#labelObject


46
47
48
# File 'app/services/hyrax/statistics/term_query.rb', line 46

def label
  @data[:label]
end

#valueObject


50
51
52
# File 'app/services/hyrax/statistics/term_query.rb', line 50

def value
  @data[:data]
end