Class: Solargraph::Source::Updater
- Inherits:
-
Object
- Object
- Solargraph::Source::Updater
- Defined in:
- lib/solargraph/source/updater.rb
Overview
Updaters contain changes to be applied to a source. The source applies the update via the Source#synchronize method.
Instance Attribute Summary collapse
- #changes ⇒ Array<Change> readonly
- #filename ⇒ String readonly
- #version ⇒ Integer readonly
Instance Method Summary collapse
-
#initialize(filename, version, changes) ⇒ Updater
constructor
A new instance of Updater.
- #repair(text) ⇒ String
- #write(text, nullable = false) ⇒ String
Constructor Details
#initialize(filename, version, changes) ⇒ Updater
Returns a new instance of Updater.
21 22 23 24 25 26 27 28 |
# File 'lib/solargraph/source/updater.rb', line 21 def initialize filename, version, changes @filename = filename @version = version @changes = changes @input = nil @did_nullify = nil @output = nil end |
Instance Attribute Details
#changes ⇒ Array<Change> (readonly)
16 17 18 |
# File 'lib/solargraph/source/updater.rb', line 16 def changes @changes end |
#filename ⇒ String (readonly)
10 11 12 |
# File 'lib/solargraph/source/updater.rb', line 10 def filename @filename end |
#version ⇒ Integer (readonly)
13 14 15 |
# File 'lib/solargraph/source/updater.rb', line 13 def version @version end |
Instance Method Details
#repair(text) ⇒ String
46 47 48 49 50 51 |
# File 'lib/solargraph/source/updater.rb', line 46 def repair text changes.each do |ch| text = ch.repair(text) end text end |
#write(text, nullable = false) ⇒ String
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/solargraph/source/updater.rb', line 33 def write text, nullable = false can_nullify = (nullable and changes.length == 1) return @output if @input == text and can_nullify == @did_nullify @input = text @output = text @did_nullify = can_nullify changes.each do |ch| @output = ch.write(@output, can_nullify) end @output end |