Class: Dsu::Migration::RawJsonFiles

Inherits:
Object
  • Object
show all
Defined in:
lib/dsu/migration/raw_json_files.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder) ⇒ RawJsonFiles

Returns a new instance of RawJsonFiles.



13
14
15
# File 'lib/dsu/migration/raw_json_files.rb', line 13

def initialize(folder)
  @folder = folder
end

Instance Attribute Details

#folderObject

Returns the value of attribute folder.



11
12
13
# File 'lib/dsu/migration/raw_json_files.rb', line 11

def folder
  @folder
end

Class Method Details

.folder_exist?(folder:) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/dsu/migration/raw_json_files.rb', line 32

def folder_exist?(folder:)
  Dir.exist?(folder)
end

Instance Method Details

#each_file(regex: //) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/dsu/migration/raw_json_files.rb', line 17

def each_file(regex: //)
  return unless folder_exist?

  Pathname.new(folder).children.each do |child|
    next unless child.file? && child.to_s.match?(regex)

    yield RawJsonFile.new(child)
  end
end

#folder_exist?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/dsu/migration/raw_json_files.rb', line 27

def folder_exist?
  self.class.folder_exist?(folder: folder)
end