Class: GoogleDataSource::DataSource::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/google_data_source/column.rb

Constant Summary collapse

COLTYPES =
%w(boolean number string date datetime timeofday)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Column

COLKEYS = [:type, :id, :label, :pattern]



9
10
11
12
13
14
# File 'lib/google_data_source/column.rb', line 9

def initialize(params)
  @type = (params[:type] || :string).to_s
  @id = params[:id].to_sym
  @label = params[:label]
  @pattern = params[:pattern]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/google_data_source/column.rb', line 4

def id
  @id
end

#labelObject

Returns the value of attribute label.



4
5
6
# File 'lib/google_data_source/column.rb', line 4

def label
  @label
end

#patternObject

Returns the value of attribute pattern.



4
5
6
# File 'lib/google_data_source/column.rb', line 4

def pattern
  @pattern
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/google_data_source/column.rb', line 4

def type
  @type
end

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
# File 'lib/google_data_source/column.rb', line 20

def to_h
  {
    :id => id,
    :type => type,
    :label => label,
    :pattern => pattern
  }
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/google_data_source/column.rb', line 16

def valid?
  COLTYPES.include?(type)
end