Class: MasterDataTool::MasterDataFile

Inherits:
Object
  • Object
show all
Defined in:
lib/master_data_tool/master_data_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec_name:, table_name:, path:, override_identifier:) ⇒ MasterDataFile

Returns a new instance of MasterDataFile.



6
7
8
9
10
11
12
# File 'lib/master_data_tool/master_data_file.rb', line 6

def initialize(spec_name:, table_name:, path:, override_identifier:)
  @spec_name = spec_name
  @table_name = table_name
  @path = path
  @override_identifier = override_identifier
  freeze
end

Instance Attribute Details

#override_identifierObject (readonly)

Returns the value of attribute override_identifier.



4
5
6
# File 'lib/master_data_tool/master_data_file.rb', line 4

def override_identifier
  @override_identifier
end

#pathObject (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/master_data_tool/master_data_file.rb', line 4

def path
  @path
end

#spec_nameObject (readonly)

Returns the value of attribute spec_name.



4
5
6
# File 'lib/master_data_tool/master_data_file.rb', line 4

def spec_name
  @spec_name
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



4
5
6
# File 'lib/master_data_tool/master_data_file.rb', line 4

def table_name
  @table_name
end

Class Method Details

.build(spec_name:, path:, override_identifier:) ⇒ Object



15
16
17
18
# File 'lib/master_data_tool/master_data_file.rb', line 15

def build(spec_name:, path:, override_identifier:)
  table_name = MasterDataTool.resolve_table_name(spec_name: spec_name, csv_path: path, override_identifier: override_identifier)
  new(spec_name: spec_name, table_name: table_name, path: path, override_identifier: override_identifier)
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



25
26
27
28
# File 'lib/master_data_tool/master_data_file.rb', line 25

def ==(other)
  other.class === self &&
    other.hash == hash
end

#basenameObject



21
22
23
# File 'lib/master_data_tool/master_data_file.rb', line 21

def basename
  @path.basename
end

#hashObject



32
33
34
# File 'lib/master_data_tool/master_data_file.rb', line 32

def hash
  [@spec_name, @table_name, @path, @override_identifier].join.hash
end