class EasyOrderable::Parser

Attributes

arg[R]

Public Class Methods

new(arg) click to toggle source
# File lib/easy_orderable/parser.rb, line 3
def initialize(arg)
  @arg = arg
end

Public Instance Methods

call() click to toggle source
# 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