Class: JsonUpdater::UpdateService

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(changeable_file_path:, etalon_file_path:) ⇒ UpdateService

Returns a new instance of UpdateService.



22
23
24
25
26
27
# File 'lib/json_updater.rb', line 22

def initialize(changeable_file_path:, etalon_file_path:)
  @changeable_file_path = changeable_file_path

  @json_changeable = JSON.parse(File.open(changeable_file_path).read)
  @json_etalon = JSON.parse(File.open(etalon_file_path).read)
end

Instance Attribute Details

#changeable_file_pathObject (readonly)

Returns the value of attribute changeable_file_path.



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

def changeable_file_path
  @changeable_file_path
end

#json_changeableObject (readonly)

Returns the value of attribute json_changeable.



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

def json_changeable
  @json_changeable
end

#json_etalonObject (readonly)

Returns the value of attribute json_etalon.



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

def json_etalon
  @json_etalon
end

Class Method Details

.update_json(changeable_file_path:, etalon_file_path:) ⇒ Object



18
19
20
# File 'lib/json_updater.rb', line 18

def self.update_json(changeable_file_path:, etalon_file_path:)
  new(changeable_file_path: changeable_file_path, etalon_file_path: etalon_file_path).update_json
end

Instance Method Details

#update_jsonObject



29
30
31
# File 'lib/json_updater.rb', line 29

def update_json
  rewrite_file
end