Skip to content

Commit

Permalink
Merge pull request #144 from projecthydra-labs/refactor_logic
Browse files Browse the repository at this point in the history
Refactor logic for readability
  • Loading branch information
mjgiarlo committed Jul 17, 2015
2 parents 57c5578 + 5ec5bbd commit 4e0e27f
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 4e0e27f

Please sign in to comment.