Class: Veneer::Conditional::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/veneer/base/conditional.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, direction = :desc) ⇒ Order

Returns a new instance of Order.



46
47
48
49
# File 'lib/veneer/base/conditional.rb', line 46

def initialize(field, direction = :desc)
  @field = field.to_sym
  @direction = direction.to_sym
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



45
46
47
# File 'lib/veneer/base/conditional.rb', line 45

def direction
  @direction
end

#fieldObject (readonly)

Returns the value of attribute field.



45
46
47
# File 'lib/veneer/base/conditional.rb', line 45

def field
  @field
end

Instance Method Details

#==(other) ⇒ Object



59
60
61
62
63
# File 'lib/veneer/base/conditional.rb', line 59

def ==(other)
  self.class ==  other.class &&
  field == other.field &&
  direction == other.direction
end

#ascending?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/veneer/base/conditional.rb', line 51

def ascending?
  direction == :asc
end

#decending?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/veneer/base/conditional.rb', line 55

def decending?
  !ascending?
end