lib/review/book/image_finder.rb in review-2.3.0 vs lib/review/book/image_finder.rb in review-2.4.0

- old
+ new

@@ -1,7 +1,7 @@ # -# Copyright (c) 2014 Minero Aoki, Kenshi Muto, Masayoshi Takahashi +# Copyright (c) 2014-2017 Minero Aoki, Kenshi Muto, Masayoshi Takahashi # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # For details of LGPL, see the file "COPYING". @@ -16,32 +16,26 @@ def initialize(basedir, chapid, builder, exts) @basedir = basedir @chapid = chapid @builder = builder @exts = exts - @entries = get_entries() + @entries = dir_entries end - def get_entries - Dir.glob(File.join(@basedir, "**{,/*/**}/*.*")).uniq + def dir_entries + Dir.glob(File.join(@basedir, '**{,/*/**}/*.*')).uniq end def add_entry(path) - unless @entries.include?(path) - @entries << path - end + @entries << path unless @entries.include?(path) @entries end def find_path(id) targets = target_list(id) targets.each do |target| - @exts.each do |ext| - if @entries.include?("#{target}#{ext}") - return "#{target}#{ext}" - end - end + @exts.each { |ext| return "#{target}#{ext}" if @entries.include?("#{target}#{ext}") } end nil end def target_list(id) @@ -63,9 +57,8 @@ # 6. <basedir>/<id>.<ext> "#{@basedir}/#{id}" ] end - end end end