Class: Rusql::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/rusql/order.rb

Constant Summary collapse

TYPES =
%i(
  asc
  desc
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, column) ⇒ Order

Returns a new instance of Order.

Raises:

  • (Exception)


11
12
13
14
15
16
17
# File 'lib/rusql/order.rb', line 11

def initialize(type, column)
  raise Exception.new("Expected type to be one of #{}") unless TYPES.include?(type)
  raise TypeException.new(Column, column.class) unless column.is_a?(Column)

  @type = type
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



4
5
6
# File 'lib/rusql/order.rb', line 4

def column
  @column
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/rusql/order.rb', line 3

def type
  @type
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/rusql/order.rb', line 19

def to_s
  "#{self.column.to_s} #{type.to_s.upcase}"
end