class Apiphobic::Parameters::Sort
Constants
- DESCENDING_PREFIX
Attributes
raw_parameters[RW]
Public Class Methods
new(raw_parameters)
click to toggle source
# File lib/apiphobic/parameters/sort.rb, line 10 def initialize(raw_parameters) self.raw_parameters = raw_parameters ? raw_parameters.split(',') : [] end
Public Instance Methods
present?()
click to toggle source
# File lib/apiphobic/parameters/sort.rb, line 14 def present? raw_parameters.any? end
to_a()
click to toggle source
# File lib/apiphobic/parameters/sort.rb, line 22 def to_a @to_a ||= raw_parameters.map do |raw_parameter| if raw_parameter.start_with?(DESCENDING_PREFIX) [raw_parameter[1..-1], 'desc'] else [raw_parameter, 'asc'] end end end
to_h()
click to toggle source
# File lib/apiphobic/parameters/sort.rb, line 18 def to_h @to_h ||= Hash[to_a] end