Class: Banco::GetFile

Inherits:
Object
  • Object
show all
Defined in:
lib/banco/get_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGetFile

Returns a new instance of GetFile.



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/banco/get_file.rb', line 6

def initialize
  @csv_file_name = gets.chomp.downcase
  if @csv_file_name == 'q'
    Viewable::farewell
    exit
  else
    file_checker_cleaner(@csv_file_name)
    @name = @csv_file_name.split('.').first
    make_name
  end
end

Instance Attribute Details

#csv_file_nameObject (readonly)

Returns the value of attribute csv_file_name.



4
5
6
# File 'lib/banco/get_file.rb', line 4

def csv_file_name
  @csv_file_name
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/banco/get_file.rb', line 4

def name
  @name
end

#summary_nameObject (readonly)

Returns the value of attribute summary_name.



4
5
6
# File 'lib/banco/get_file.rb', line 4

def summary_name
  @summary_name
end

Instance Method Details

#file_checker_cleaner(filename) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/banco/get_file.rb', line 25

def file_checker_cleaner(filename)
  if filename =~ /([^\s]+(\.csv)$)/
    puts "\nloading #{filename}..."
  else
    puts "#{filename} isn't a valid file for Banco !".center(54)
    throw
  end
end

#make_nameObject



18
19
20
21
22
23
# File 'lib/banco/get_file.rb', line 18

def make_name
  @name = @csv_file_name.split('.').first
  @doctype = @csv_file_name.split('.').last
  @summary_name = @name
  @csv_file_name
end