Class: EasyOrderable::Parser
- Inherits:
-
Object
- Object
- EasyOrderable::Parser
- Defined in:
- lib/easy_orderable/parser.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(arg) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(arg) ⇒ Parser
Returns a new instance of Parser.
3 4 5 |
# File 'lib/easy_orderable/parser.rb', line 3 def initialize(arg) @arg = arg end |
Instance Method Details
#call ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/easy_orderable/parser.rb', line 7 def call elems = arg.split(',') elems.each_with_object({}) do |e, memo| if e.start_with?('-') memo[e[1..-1]] = :desc else memo[e] = :asc end end end |