Class: EhbrsRubyUtils::Fs::ToFileFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/fs/to_file_format.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.convert_self(file) ⇒ Object



18
19
20
# File 'lib/ehbrs_ruby_utils/fs/to_file_format.rb', line 18

def convert_self(file)
  new(file).run
end

.convert_to_file(source, target) ⇒ Object



22
23
24
25
# File 'lib/ehbrs_ruby_utils/fs/to_file_format.rb', line 22

def convert_to_file(source, target)
  ::FileUtils.cp(source, target)
  convert_self(target)
end

.convert_to_string(source) ⇒ Object



27
28
29
30
31
32
# File 'lib/ehbrs_ruby_utils/fs/to_file_format.rb', line 27

def convert_to_string(source)
  ::EacRubyUtils::Fs::Temp.on_file do |target|
    convert_to_file(source, target)
    target.open('rb', &:read)
  end
end

Instance Method Details

#runObject



35
36
37
38
39
40
# File 'lib/ehbrs_ruby_utils/fs/to_file_format.rb', line 35

def run
  return false unless convert?

  convert
  true
end