Class: Bmg::Ordering::Attributes
- Inherits:
-
Object
- Object
- Bmg::Ordering::Attributes
- Includes:
- Bmg::Ordering
- Defined in:
- lib/bmg/support/ordering.rb
Overview
class Native
Instance Attribute Summary collapse
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
Instance Method Summary collapse
- #comparator ⇒ Object
-
#initialize(attrs) ⇒ Attributes
constructor
A new instance of Attributes.
- #to_pairs ⇒ Object
Methods included from Bmg::Ordering
Constructor Details
#initialize(attrs) ⇒ Attributes
Returns a new instance of Attributes.
45 46 47 48 49 50 51 |
# File 'lib/bmg/support/ordering.rb', line 45 def initialize(attrs) @attrs = if attrs.empty? [] else attrs.map{|a| a.is_a?(Symbol) ? [a, :asc] : a } end end |
Instance Attribute Details
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
52 53 54 |
# File 'lib/bmg/support/ordering.rb', line 52 def attrs @attrs end |
Instance Method Details
#comparator ⇒ Object
54 55 56 |
# File 'lib/bmg/support/ordering.rb', line 54 def comparator @comparator ||= ->(t1, t2) { compare_attrs(t1, t2) } end |
#to_pairs ⇒ Object
58 59 60 |
# File 'lib/bmg/support/ordering.rb', line 58 def to_pairs attrs.to_a end |