Class: GemfileLocker::FileEditor
- Inherits:
-
Object
- Object
- GemfileLocker::FileEditor
- Defined in:
- lib/gemfile_locker/file_editor.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Instance Method Summary collapse
-
#initialize(path, processor) ⇒ FileEditor
constructor
A new instance of FileEditor.
- #result ⇒ Object
- #run ⇒ Object
- #source ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(path, processor) ⇒ FileEditor
Returns a new instance of FileEditor.
5 6 7 8 |
# File 'lib/gemfile_locker/file_editor.rb', line 5 def initialize(path, processor) @path = path @processor = processor end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/gemfile_locker/file_editor.rb', line 3 def path @path end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
3 4 5 |
# File 'lib/gemfile_locker/file_editor.rb', line 3 def processor @processor end |
Instance Method Details
#result ⇒ Object
18 19 20 |
# File 'lib/gemfile_locker/file_editor.rb', line 18 def result @result ||= processor.call(source) end |
#run ⇒ Object
10 11 12 |
# File 'lib/gemfile_locker/file_editor.rb', line 10 def run write end |
#source ⇒ Object
14 15 16 |
# File 'lib/gemfile_locker/file_editor.rb', line 14 def source @source ||= File.read(path) end |
#write ⇒ Object
22 23 24 |
# File 'lib/gemfile_locker/file_editor.rb', line 22 def write File.write(path, result) end |