Class: Igniter::LedgerClient::Results::QueryResult

Inherits:
Object
  • Object
show all
Includes:
HashAccess
Defined in:
lib/igniter/ledger_client/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashAccess

#[]

Constructor Details

#initialize(raw = {}) ⇒ QueryResult

Returns a new instance of QueryResult.



129
130
131
132
133
134
135
# File 'lib/igniter/ledger_client/results.rb', line 129

def initialize(raw = {})
  data = normalize(raw)
  @items = normalize_items(data[:items]).freeze
  @results = Array(data[:results] || items.map { |item| item[:value] }).freeze
  @count = data.key?(:count) ? data[:count].to_i : [items.size, results.size].max
  freeze
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



127
128
129
# File 'lib/igniter/ledger_client/results.rb', line 127

def count
  @count
end

#itemsObject (readonly)

Returns the value of attribute items.



127
128
129
# File 'lib/igniter/ledger_client/results.rb', line 127

def items
  @items
end

#resultsObject (readonly)

Returns the value of attribute results.



127
128
129
# File 'lib/igniter/ledger_client/results.rb', line 127

def results
  @results
end

Instance Method Details

#to_hObject



137
138
139
# File 'lib/igniter/ledger_client/results.rb', line 137

def to_h
  { items: items, results: results, count: count }
end