Module: RocketApi::Commands::Files
- Included in:
- RocketCommands
- Defined in:
- lib/rocket_api/commands/files.rb
Instance Method Summary collapse
- #class_name_camel(name) ⇒ Object
-
#create_single_file(name, text, **options) ⇒ Object
…
- #is_exist?(dir_name) ⇒ Boolean
Instance Method Details
#class_name_camel(name) ⇒ Object
10 11 12 |
# File 'lib/rocket_api/commands/files.rb', line 10 def class_name_camel(name) name.split('_').map(&:capitalize).join end |
#create_single_file(name, text, **options) ⇒ Object
…
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rocket_api/commands/files.rb', line 19 def create_single_file(name, text, **) raise "#{RocketApi::FILE_EXIST} #{name}" if is_exist?(name) out_file = File.new(name, "w") out_file.chmod(001) if [:exe] out_file.puts(text) out_file.close puts "#{RocketApi::CREATE_SUCCESS} #{name}" rescue StandardError => e raise e, "#{name} err: #{e.}" end |
#is_exist?(dir_name) ⇒ Boolean
5 6 7 |
# File 'lib/rocket_api/commands/files.rb', line 5 def is_exist?(dir_name) File.exist?(dir_name) end |