Class: Igniter::LedgerClient::Results::QueryResult
- Inherits:
-
Object
- Object
- Igniter::LedgerClient::Results::QueryResult
- Includes:
- HashAccess
- Defined in:
- lib/igniter/ledger_client/results.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
-
#initialize(raw = {}) ⇒ QueryResult
constructor
A new instance of QueryResult.
- #to_h ⇒ Object
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
#count ⇒ Object (readonly)
Returns the value of attribute count.
127 128 129 |
# File 'lib/igniter/ledger_client/results.rb', line 127 def count @count end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
127 128 129 |
# File 'lib/igniter/ledger_client/results.rb', line 127 def items @items end |
#results ⇒ Object (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_h ⇒ Object
137 138 139 |
# File 'lib/igniter/ledger_client/results.rb', line 137 def to_h { items: items, results: results, count: count } end |