Class: Xpub::CallBook::CallImgFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/xpub/dsl/src_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ CallImgFiles

Returns a new instance of CallImgFiles.



40
41
42
# File 'lib/xpub/dsl/src_file.rb', line 40

def initialize(dir)
  @dir = dir
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



38
39
40
# File 'lib/xpub/dsl/src_file.rb', line 38

def dir
  @dir
end

Instance Method Details

#full_pathObject



44
45
46
# File 'lib/xpub/dsl/src_file.rb', line 44

def full_path
  "#{Dir.getwd}/src/#{@dir}"
end

#img_filesObject



52
53
54
55
56
57
58
59
# File 'lib/xpub/dsl/src_file.rb', line 52

def img_files
  validate
  Dir.glob("#{full_path}/**/*.{jpeg,jpg,png,bmp,pdf}").sort.map do |path|
    img = CallImgFile.new path.sub(full_path + '/', '')
    img.validate
    img
  end
end

#validateObject



48
49
50
# File 'lib/xpub/dsl/src_file.rb', line 48

def validate
  raise "Image Dir does not exist.#{full_path}" unless Dir.exist? full_path
end