Class: ConvenientService::Examples::Standard::Gemfile::Services::AssertFileExists
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::Gemfile::Services::AssertFileExists
- Includes:
- Service::Configs::Standard
- Defined in:
- lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path:) ⇒ AssertFileExists
constructor
A new instance of AssertFileExists.
- #result ⇒ Object
Methods included from Service::Configs::Standard
Methods included from Config
Constructor Details
#initialize(path:) ⇒ AssertFileExists
Returns a new instance of AssertFileExists.
18 19 20 |
# File 'lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb', line 18 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb', line 16 def path @path end |
Instance Method Details
#result ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/convenient_service/examples/standard/gemfile/services/assert_file_exists.rb', line 22 def result return error("Path is `nil`") if path.nil? return error("Path is empty") if path.empty? return failure("File with path `#{path}` does NOT exist") unless ::File.exist?(path) success end |