Class: SmqlToAR::Column::Col
- Inherits:
-
Object
- Object
- SmqlToAR::Column::Col
- Includes:
- Comparable
- Defined in:
- lib/smql_to_ar.rb
Instance Attribute Summary collapse
-
#as ⇒ Object
Returns the value of attribute as.
-
#col ⇒ Object
Returns the value of attribute col.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #===(other) ⇒ Object
-
#initialize(col, as = nil) ⇒ Col
constructor
A new instance of Col.
- #inspect ⇒ Object
- #to_alias ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
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
#as ⇒ Object
Returns the value of attribute as.
124 125 126 |
# File 'lib/smql_to_ar.rb', line 124 def as @as end |
#col ⇒ Object
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 |
#inspect ⇒ Object
138 |
# File 'lib/smql_to_ar.rb', line 138 def inspect() "#{@col}[@#{@as}]" end |
#to_alias ⇒ Object
139 |
# File 'lib/smql_to_ar.rb', line 139 def to_alias() "#{@col}[#{@as}]" end |
#to_s ⇒ Object
136 |
# File 'lib/smql_to_ar.rb', line 136 def to_s() @col end |
#to_sym ⇒ Object
137 |
# File 'lib/smql_to_ar.rb', line 137 def to_sym() to_s.to_sym end |