Skip to content

Commit

Permalink
Refactor logic for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jul 13, 2015
1 parent f5a5f4e commit 5ec5bbd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/hydra/works/models/concerns/generic_file/mime_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ def collection?
end

def file_format
return nil if mime_type.blank? and format_label.blank?
return mime_type.split('/')[1]+ " ("+format_label.join(", ")+")" unless mime_type.blank? or format_label.blank?
return mime_type.split('/')[1] unless mime_type.blank?
return format_label
if mime_type.present? && format_label.present?
"#{mime_type.split('/').last} (#{format_label.join(", ")})"
elsif mime_type.present?
mime_type.split('/').last
elsif format_label.present?
format_label
else
nil
end
end

module ClassMethods
Expand Down

0 comments on commit 5ec5bbd

Please sign in to comment.