Class: Cpro::Entities::ResultatRecherche
- Includes:
- Enumerable
- Defined in:
- lib/cpro/entities/resultat_recherche.rb
Instance Attribute Summary collapse
-
#item_class ⇒ Object
readonly
Les deux API ne nomment pas le total de la même façon —
nombre_total_resultatspour l'Annuaire,nombreTotalResultatspour Recherche Factures — d'où la clé explicite. -
#total_key ⇒ Object
readonly
Les deux API ne nomment pas le total de la même façon —
nombre_total_resultatspour l'Annuaire,nombreTotalResultatspour Recherche Factures — d'où la clé explicite.
Attributes inherited from Base
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #ignores ⇒ Object
-
#initialize(payload, item_class:, total_key:) ⇒ ResultatRecherche
constructor
A new instance of ResultatRecherche.
-
#limite ⇒ Object
Renseignés par Recherche Factures seulement : la recherche d'annuaire ne retourne pas ses paramètres de pagination.
- #nombre_total ⇒ Object
- #resultats ⇒ Object
- #size ⇒ Object (also: #length)
Methods inherited from Base
Constructor Details
#initialize(payload, item_class:, total_key:) ⇒ ResultatRecherche
Returns a new instance of ResultatRecherche.
12 13 14 15 16 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 12 def initialize(payload, item_class:, total_key:) super(payload) @item_class = item_class @total_key = total_key end |
Instance Attribute Details
#item_class ⇒ Object (readonly)
Les deux API ne nomment pas le total de la même façon — nombre_total_resultats pour
l'Annuaire, nombreTotalResultats pour Recherche Factures — d'où la clé explicite.
10 11 12 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 10 def item_class @item_class end |
#total_key ⇒ Object (readonly)
Les deux API ne nomment pas le total de la même façon — nombre_total_resultats pour
l'Annuaire, nombreTotalResultats pour Recherche Factures — d'où la clé explicite.
10 11 12 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 10 def total_key @total_key end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
49 50 51 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 49 def ==(other) super && other.item_class == item_class end |
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 22 def each(&block) resultats.each(&block) end |
#empty? ⇒ Boolean
45 46 47 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 45 def empty? resultats.empty? end |
#ignores ⇒ Object
36 37 38 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 36 def ignores payload["ignores"] end |
#limite ⇒ Object
Renseignés par Recherche Factures seulement : la recherche d'annuaire ne retourne pas ses
paramètres de pagination. Combinés à nombre_total, ils permettent de paginer.
32 33 34 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 32 def limite payload["limite"] end |
#nombre_total ⇒ Object
26 27 28 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 26 def nombre_total payload[total_key] end |
#resultats ⇒ Object
18 19 20 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 18 def resultats @resultats ||= Array(payload["resultats"]).map { |item| item_class.new(item) } end |
#size ⇒ Object Also known as: length
40 41 42 |
# File 'lib/cpro/entities/resultat_recherche.rb', line 40 def size resultats.size end |