Class: Lookbook::SearchParamParser

Inherits:
Service
  • Object
show all
Defined in:
lib/lookbook/services/urls/search_param_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(param_value) ⇒ SearchParamParser

Returns a new instance of SearchParamParser.



5
6
7
# File 'lib/lookbook/services/urls/search_param_parser.rb', line 5

def initialize(param_value)
  @param_value = param_value.strip
end

Instance Attribute Details

#param_valueObject (readonly)

Returns the value of attribute param_value.



3
4
5
# File 'lib/lookbook/services/urls/search_param_parser.rb', line 3

def param_value
  @param_value
end

Instance Method Details

#callObject



9
10
11
12
13
# File 'lib/lookbook/services/urls/search_param_parser.rb', line 9

def call
  pairs_str = param_value.split("|")
  pairs = pairs_str.map { |pair| [*pair.split(":").map(&:strip)] }
  pairs.to_h.symbolize_keys
end