class NexosisApi::SessionResult

Class for parsing the results of a completed session

Attributes

data[RW]

The result data in a hash with the name of the target column @return [NexosisApi::PagedArray of Hash] @note When retrieving a model creation session this field will contain the test data and results.

metrics[RW]

The impact analysis if this session type is impact @return [NexosisApi::ImpactMetric]

Public Class Methods

new(session_hash) click to toggle source
Calls superclass method NexosisApi::Session::new
# File lib/nexosis_api/session_result.rb, line 4
def initialize(session_hash)
  session_hash.each do |k, v|
    if k.to_s == 'metrics' && session_hash['type'] == 'impact'
      instance_variable_set("@#{k}", NexosisApi::ImpactMetric.new(v)) unless v.nil?
    elsif k.to_s == 'metrics'
      @metrics = v.map { |key, value| NexosisApi::Metric.new(key.to_s, value) } unless v.nil?
    elsif k.to_s == 'data'
      @data = NexosisApi::PagedArray.new(session_hash, v)
    end
  end
  super(session_hash.reject { |k, _v| k.to_s == 'data' || k.to_s == 'metrics' })
end