Class: Tablesmith::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/tablesmith/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Column

Returns a new instance of Column.



151
152
153
154
155
# File 'lib/tablesmith/table.rb', line 151

def initialize(attributes = {})
  @source = attributes.delete(:source)
  @name = attributes.delete(:name)
  @alias = attributes.delete(:alias)
end

Instance Attribute Details

#aliasObject

Returns the value of attribute alias.



149
150
151
# File 'lib/tablesmith/table.rb', line 149

def alias
  @alias
end

#nameObject

Returns the value of attribute name.



149
150
151
# File 'lib/tablesmith/table.rb', line 149

def name
  @name
end

#sourceObject

Returns the value of attribute source.



149
150
151
# File 'lib/tablesmith/table.rb', line 149

def source
  @source
end

Instance Method Details

#display_nameObject



157
158
159
# File 'lib/tablesmith/table.rb', line 157

def display_name
  (@alias || @name).to_s
end

#full_unaliased_nameObject



161
162
163
# File 'lib/tablesmith/table.rb', line 161

def full_unaliased_name
  "#{@source ? "#{@source}." : ''}#{@name}"
end

#to_sObject



165
166
167
# File 'lib/tablesmith/table.rb', line 165

def to_s
  "#{@source}.#{@name}#{' as ' + @alias if @alias}"
end