user1310656 user1310656 - 1 year ago 100
Ruby Question

ruby long line wrap up

How to wrap up this long line so not break the maximum 80 length rule? At where to break the line?

raise XxxxxxxxxxxxxxxxxxxxxxError unless [HTTP_STATUS_CODE[:OK], HTTP_STATUS_CODE[:xxxxxxxxxxxxxx]].include? http_status_code

Answer Source

You can break unless into a multi-line block. I'll suggest that you extract the array out into a variable perhaps?

accepted_codes = [HTTP_STATUS_CODE[:OK], HTTP_STATUS_CODE[:created]]
unless accepted codes.include? http_status_code
  raise StandardError
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download