Class: SmqlToAR::Column::Col

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/smql_to_ar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(col, as = nil) ⇒ Col

Returns a new instance of Col.



125
126
127
128
129
130
131
132
133
134
# File 'lib/smql_to_ar.rb', line 125

def initialize col, as = nil
  if col.kind_of? Col
    @col, @as = col.col, col.as
  elsif /^(.*?)\[(.*)\]$/ =~ col.to_s
    @col, @as = $1, $2
  else
    @col, @as = col.to_s, as.to_s
    @as = nil  if @as.blank?
  end
end

Instance Attribute Details

#asObject

Returns the value of attribute as.



124
125
126
# File 'lib/smql_to_ar.rb', line 124

def as
  @as
end

#colObject

Returns the value of attribute col.



124
125
126
# File 'lib/smql_to_ar.rb', line 124

def col
  @col
end

Instance Method Details

#==(other) ⇒ Object



141
142
143
144
# File 'lib/smql_to_ar.rb', line 141

def == other
  other = Col.new other
  @col == other.col  &&  @as == other.as
end

#===(other) ⇒ Object



146
147
148
# File 'lib/smql_to_ar.rb', line 146

def === other
  @col == Col.new( other).col
end

#inspectObject



138
# File 'lib/smql_to_ar.rb', line 138

def inspect()  "#{@col}[@#{@as}]"  end

#to_aliasObject



139
# File 'lib/smql_to_ar.rb', line 139

def to_alias()  "#{@col}[#{@as}]"  end

#to_sObject



136
# File 'lib/smql_to_ar.rb', line 136

def to_s()  @col  end

#to_symObject



137
# File 'lib/smql_to_ar.rb', line 137

def to_sym()  to_s.to_sym  end