Class: PiSlides::ImageDir

Inherits:
Struct
  • Object
show all
Defined in:
lib/pi_slides/image_dir.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



3
4
5
# File 'lib/pi_slides/image_dir.rb', line 3

def path
  @path
end

Instance Method Details

#file_list(pattern = '**/*.jpg') ⇒ Object



4
5
6
# File 'lib/pi_slides/image_dir.rb', line 4

def file_list(pattern = '**/*.jpg')
  @file_list ||= Dir[File.join(path, pattern)].shuffle
end

#random_fileObject



12
13
14
# File 'lib/pi_slides/image_dir.rb', line 12

def random_file
  file_list.pop
end

#resetObject



8
9
10
# File 'lib/pi_slides/image_dir.rb', line 8

def reset
  @file_list = nil
end

#sizeObject



16
17
18
# File 'lib/pi_slides/image_dir.rb', line 16

def size
  file_list.size
end