Class: ConvenientService::Utils::String::Enclose
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::Utils::String::Enclose
- Defined in:
- lib/convenient_service/utils/string/enclose.rb
Instance Attribute Summary collapse
-
#char ⇒ Object
readonly
Returns the value of attribute char.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #call ⇒ String
- #initialize(string, char) ⇒ void constructor
Methods inherited from Support::Command
Constructor Details
#initialize(string, char) ⇒ void
35 36 37 38 |
# File 'lib/convenient_service/utils/string/enclose.rb', line 35 def initialize(string, char) @string = string @char = char end |
Instance Attribute Details
#char ⇒ Object (readonly)
Returns the value of attribute char.
28 29 30 |
# File 'lib/convenient_service/utils/string/enclose.rb', line 28 def char @char end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
22 23 24 |
# File 'lib/convenient_service/utils/string/enclose.rb', line 22 def string @string end |
Instance Method Details
#call ⇒ String
43 44 45 46 47 48 |
# File 'lib/convenient_service/utils/string/enclose.rb', line 43 def call return char unless string return char if string.empty? "#{char}#{string}#{char}" end |