Class: ConvenientService::Examples::Standard::Gemfile::Services::MergeSections
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::Gemfile::Services::MergeSections
- Includes:
- Service::Configs::Standard
- Defined in:
- lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
-
#initialize(header:, body:) ⇒ MergeSections
constructor
A new instance of MergeSections.
- #result ⇒ Object
- #validate_body ⇒ Object
- #validate_header ⇒ Object
Constructor Details
#initialize(header:, body:) ⇒ MergeSections
Returns a new instance of MergeSections.
25 26 27 28 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 25 def initialize(header:, body:) @header = header @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
11 12 13 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 11 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
11 12 13 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 11 def header @header end |
Instance Method Details
#result ⇒ Object
30 31 32 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 30 def result success(merged_sections: "#{header}\n#{body}") end |
#validate_body ⇒ Object
41 42 43 44 45 46 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 41 def validate_body return error("Body is `nil`") if body.nil? return error("Body is empty") if body.empty? success end |
#validate_header ⇒ Object
34 35 36 37 38 39 |
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 34 def validate_header return error("Header is `nil`") if header.nil? return error("Header is empty") if header.empty? success end |