Method: Cnvrg::Dataset#initialize

Defined in:
lib/cnvrg/dataset.rb

#initialize(project_home = '', dataset_url: '', dataset_info: '') ⇒ Dataset

Returns a new instance of Dataset.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cnvrg/dataset.rb', line 10

def initialize(project_home = '', dataset_url: '', dataset_info: '')
  begin
    @info = {}
    if project_home.present?
      @local_path = project_home
      @working_dir = project_home
      config = Cnvrg::Helpers.get_config_v2_dataset(project_home)
      @title = config[:dataset_name]
      @slug = config[:dataset_slug]
      @owner = config[:owner]
    elsif dataset_info.present?
      @title = dataset_info[:slug]
      @slug = dataset_info[:slug]
      @owner = dataset_info[:owner]
      @local_path = Dir.pwd
    else
      owner, slug = Cnvrg::Helpers.extract_owner_slug_from_url(dataset_url, 'datasets')
      @title = slug
      @slug = slug
      @owner = owner
      @local_path = Dir.pwd
    end
  rescue => e

  end
end