Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring: fix some style issues #116

Merged
merged 3 commits into from
Nov 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/rakuten_web_service/recipe/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def ranking

def parent_category
return nil if parent_category_type.nil?
Recipe.categories(parent_category_type).find { |c| c.id.to_i == parent_category_id.to_i }
Recipe.categories(parent_category_type).find do |c|
c.id.to_i == parent_category_id.to_i
end
end

def absolute_category_id
Expand Down
21 changes: 10 additions & 11 deletions lib/rakuten_web_service/search_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,19 @@ def params_to_get_next_page

def order(options)
new_params = params.dup
if options.is_a? Hash
key, sort_order = *options.to_a.last
key = key.to_s.to_camel
new_params[:sort] = case sort_order.to_s.downcase
when 'desc'
"-#{key}"
when 'asc'
"+#{key}"
end
elsif options.to_s == 'standard'
if options.to_s == 'standard'
new_params[:sort] = 'standard'
else
return self.class.new(new_params, @resource_class)
end
unless options.is_a? Hash
raise ArgumentError, "Invalid Sort Option: #{options.inspect}"
end

key, sort_order = *options.to_a.last
case sort_order.to_s.downcase
when 'desc' then new_params[:sort] = "-#{key}".to_camel
when 'asc' then new_params[:sort] = "+#{key}".to_camel
end
self.class.new(new_params, @resource_class)
end

Expand Down
6 changes: 3 additions & 3 deletions lib/rakuten_web_service/travel/area_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def search(options = {})
end

def [](class_code)
LargeClass[class_code] or
MiddleClass[class_code] or
SmallClass[class_code] or
LargeClass[class_code] ||
MiddleClass[class_code] ||
SmallClass[class_code] ||
DetailClass[class_code]
end
module_function :search, :[]
Expand Down