Class: NexosisApi::ViewDefinition
- Inherits:
-
Object
- Object
- NexosisApi::ViewDefinition
- Defined in:
- lib/nexosis_api/view_definition.rb
Overview
class to hold the parsed results of a view
Direct Known Subclasses
Instance Attribute Summary collapse
-
#column_metadata ⇒ Array of NexosisApi::Column
Descriptive information about the columns.
-
#dataset_name ⇒ String
The name of the dataset on the left of the join.
-
#is_timeseries ⇒ Object
(also: #timeseries?)
Is this view based on time series data?.
-
#joins ⇒ Array of NexosisApi::Join
The join configuration for this view.
-
#view_name ⇒ String
The name of the view uploaded and saved.
Instance Method Summary collapse
-
#initialize(view_hash) ⇒ ViewDefinition
constructor
A new instance of ViewDefinition.
-
#to_json ⇒ Object
Provides a custom hash which matches json of api request.
Constructor Details
#initialize(view_hash) ⇒ ViewDefinition
Returns a new instance of ViewDefinition.
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_metadata ⇒ Array of NexosisApi::Column
Descriptive information about the columns
33 34 35 |
# File 'lib/nexosis_api/view_definition.rb', line 33 def @column_metadata end |
#dataset_name ⇒ String
The name of the dataset on the left of the join
29 30 31 |
# File 'lib/nexosis_api/view_definition.rb', line 29 def dataset_name @dataset_name end |
#is_timeseries ⇒ Object Also known as: timeseries?
Is this view based on time series data?
41 42 43 |
# File 'lib/nexosis_api/view_definition.rb', line 41 def is_timeseries @is_timeseries end |
#joins ⇒ Array of NexosisApi::Join
The join configuration for this view
37 38 39 |
# File 'lib/nexosis_api/view_definition.rb', line 37 def joins @joins end |
#view_name ⇒ String
The name of the view uploaded and saved
25 26 27 |
# File 'lib/nexosis_api/view_definition.rb', line 25 def view_name @view_name end |
Instance Method Details
#to_json ⇒ Object
Provides a custom hash which matches json of api request
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 |