Class: ConvenientService::Examples::Standard::V1::Gemfile::Services::AssertFileExists
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::V1::Gemfile::Services::AssertFileExists
- Includes:
- Service::Configs::Standard::V1
- Defined in:
- lib/convenient_service/examples/standard/v1/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
Constructor Details
#initialize(path:) ⇒ AssertFileExists
Returns a new instance of AssertFileExists.
14 15 16 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb', line 14 def initialize(path:) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb', line 12 def path @path end |
Instance Method Details
#result ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/assert_file_exists.rb', line 18 def result return failure(path: "Path is `nil`") if path.nil? return failure(path: "Path is empty") if path.empty? return error("File with path `#{path}` does NOT exist") unless ::File.exist?(path) success end |