Class: ConvenientService::Utils::Method::Name::Append

Inherits:
Support::Command show all
Defined in:
lib/convenient_service/utils/method/name/append.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(method_name, method_suffix) ⇒ void

Parameters:

  • method_name (String, Symbol)
  • method_suffix (String, Symbol)


30
31
32
33
# File 'lib/convenient_service/utils/method/name/append.rb', line 30

def initialize(method_name, method_suffix)
  @method_name = method_name.to_s
  @method_suffix = method_suffix.to_s
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



17
18
19
# File 'lib/convenient_service/utils/method/name/append.rb', line 17

def method_name
  @method_name
end

#method_suffixObject (readonly)

Returns the value of attribute method_suffix.



23
24
25
# File 'lib/convenient_service/utils/method/name/append.rb', line 23

def method_suffix
  @method_suffix
end

Instance Method Details

#callString

Returns:



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/convenient_service/utils/method/name/append.rb', line 38

def call
  return "" if method_name.empty?

  if method_name.end_with?("!")
    "#{method_name.delete_suffix("!")}#{method_suffix}!"
  elsif method_name.end_with?("?")
    "#{method_name.delete_suffix("?")}#{method_suffix}?"
  else
    "#{method_name}#{method_suffix}"
  end
end