Class: NexosisApi::ColumnOptions

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

Overview

Class for holding the join options on a column in a view-based join

Since:

  • 1.2.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(column_name, options_hash) ⇒ ColumnOptions

Create a new option for a join column.

Parameters:

  • column_name (String)

    the name of the original column from the source dataset

  • options_hash (Hash)

    additional information about how to process the column in a join

Since:

  • 1.2.0



8
9
10
11
12
# File 'lib/nexosis_api/column_options.rb', line 8

def initialize(column_name, options_hash)
  @column_name = column_name
  @join_interval = NexosisApi::TimeInterval.const_get(options_hash['joinInterval'].upcase) unless options_hash['joinInterval'].nil?
  @alias = options_hash['alias']
end

Instance Attribute Details

#aliasString

Note:

An alias can be used to keep two same-named columns distinct

Optional alias of the column when participating in a join or to merge two distinctly named columns. By default same-named columns on two sides of a join will be merged.

Returns:

  • (String)

Since:

  • 1.2.0



28
29
30
# File 'lib/nexosis_api/column_options.rb', line 28

def alias
  @alias
end

#column_nameString

The name of the column on which these options are applied

Returns:

  • (String)

Since:

  • 1.2.0



16
17
18
# File 'lib/nexosis_api/column_options.rb', line 16

def column_name
  @column_name
end

#join_intervalNexosisApi::TimeInterval

Note:

not valid outside of join defintion

Optional interval of a time series column being joined to another time series

Returns:

Since:

  • 1.2.0



21
22
23
# File 'lib/nexosis_api/column_options.rb', line 21

def join_interval
  @join_interval
end

Instance Method Details

#to_hashObject

builds a custom hash which will match api requests

Since:

  • 1.2.0



31
32
33
34
35
36
# File 'lib/nexosis_api/column_options.rb', line 31

def to_hash
  hash = { column_name => {} }
  hash[column_name]['join_interval'] = join_interval.to_s unless join_interval.nil?
  hash[column_name]['alias'] = @alias.to_s unless @alias.nil?
  hash
end