Sha256: 729e2d2fdd87a13f65e3491a549b2440d48f972fd315df9c3f7d0546dcbcc520
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true ## # @example Common usage. # ConvenientService::Utils::String::Enclose.call("foo", "_") # # => "_foo_" # # ConvenientService::Utils::String::Enclose.call("", "_") # # => "_" # # ConvenientService::Utils::String::Enclose.call(nil, "_") # # => "_" # module ConvenientService module Utils module String class Enclose < Support::Command ## # @!attribute [r] string # @return [String] # attr_reader :string ## # @!attribute [r] char # @return [String] # attr_reader :char ## # @param string [String] # @param char [String] # @return [void] # def initialize(string, char) @string = string @char = char end ## # @return [String] # def call return char unless string return char if string.empty? "#{char}#{string}#{char}" end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
convenient_service-0.19.1 | lib/convenient_service/utils/string/enclose.rb |
convenient_service-0.19.0 | lib/convenient_service/utils/string/enclose.rb |