Class: Iriq::Observation
- Inherits:
-
Object
- Object
- Iriq::Observation
- Defined in:
- lib/iriq/observation.rb
Overview
The result of Corpus#observe. Lightweight value object — heavy work (cluster load, explanation, normalization) is deferred until you ask.
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
-
#cluster ⇒ Object
The cluster as it stands when first read; observing doesn't load it.
- #explanation ⇒ Object
- #fingerprint ⇒ Object
-
#initialize(corpus:, identifier:, cluster_key:) ⇒ Observation
constructor
A new instance of Observation.
- #normalize ⇒ Object
Constructor Details
#initialize(corpus:, identifier:, cluster_key:) ⇒ Observation
Returns a new instance of Observation.
7 8 9 10 11 |
# File 'lib/iriq/observation.rb', line 7 def initialize(corpus:, identifier:, cluster_key:) @corpus = corpus @identifier = identifier @cluster_key = cluster_key end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/iriq/observation.rb', line 5 def identifier @identifier end |
Instance Method Details
#cluster ⇒ Object
The cluster as it stands when first read; observing doesn't load it.
14 15 16 |
# File 'lib/iriq/observation.rb', line 14 def cluster @cluster ||= @corpus.storage.cluster_for(@cluster_key) end |
#explanation ⇒ Object
22 23 24 |
# File 'lib/iriq/observation.rb', line 22 def explanation @explanation ||= @corpus.explain(@identifier) end |
#fingerprint ⇒ Object
18 19 20 |
# File 'lib/iriq/observation.rb', line 18 def fingerprint @fingerprint ||= Normalizer.normalize_identifier(@identifier) end |
#normalize ⇒ Object
26 27 28 |
# File 'lib/iriq/observation.rb', line 26 def normalize @corpus.normalize(@identifier) end |