Class: NexosisApi::ViewDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/nexosis_api/view_definition.rb

Overview

class to hold the parsed results of a view

Since:

  • 1.2.0

Direct Known Subclasses

ViewData

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_hash) ⇒ ViewDefinition

Returns a new instance of ViewDefinition.

Since:

  • 1.2.0



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/nexosis_api/view_definition.rb', line 5

def initialize(view_hash)
  view_hash.each do |k, v|
    if k == 'viewName'
      @view_name = v unless v.nil?
    elsif k == 'dataSetName'
      @dataset_name = v unless v.nil?
    elsif k == 'columns'
      next if v.nil?
      @column_metadata = v.reject { |value| value.nil? } .map { |col_name, col_hash| NexosisApi::Column.new(col_name, col_hash)}
    elsif k == 'joins'
      next if v.nil?
      @joins = v.reject(&:nil?).map { |join| NexosisApi::Join.new(join) }
    elsif k == 'isTimeSeries'
      @is_timeseries = v
    end
  end
end

Instance Attribute Details

#column_metadataArray of NexosisApi::Column

Descriptive information about the columns

Returns:

Since:

  • 1.2.0



33
34
35
# File 'lib/nexosis_api/view_definition.rb', line 33

def 
  @column_metadata
end

#dataset_nameString

The name of the dataset on the left of the join

Returns:

  • (String)

Since:

  • 1.2.0



29
30
31
# File 'lib/nexosis_api/view_definition.rb', line 29

def dataset_name
  @dataset_name
end

#is_timeseriesObject Also known as: timeseries?

Is this view based on time series data?

Since:

  • 1.3.0



41
42
43
# File 'lib/nexosis_api/view_definition.rb', line 41

def is_timeseries
  @is_timeseries
end

#joinsArray of NexosisApi::Join

The join configuration for this view

Returns:

Since:

  • 1.2.0



37
38
39
# File 'lib/nexosis_api/view_definition.rb', line 37

def joins
  @joins
end

#view_nameString

The name of the view uploaded and saved

Returns:

  • (String)

Since:

  • 1.2.0



25
26
27
# File 'lib/nexosis_api/view_definition.rb', line 25

def view_name
  @view_name
end

Instance Method Details

#to_jsonObject

Provides a custom hash which matches json of api request

Since:

  • 1.2.0



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/nexosis_api/view_definition.rb', line 48

def to_json
  hash = {}
  hash['dataSetName'] = dataset_name
  if .nil? == false
    hash['columns'] = {}
    .each do |column|
      hash['columns'].merge!(column.to_hash)
    end
  end
  hash['joins'] = []
  joins.each do |join|
    hash['joins'] << join.to_hash
  end
  hash.to_json
end