Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::SubMatchers::Arguments::Commands::GeneratePrintableArguments

Inherits:
Support::Command
  • Object
show all
Includes:
Support::Delegate
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support::Delegate::ClassMethodsForForwardable

#delegate

Methods inherited from Support::Command

[], call

Constructor Details

#initialize(arguments:) ⇒ GeneratePrintableArguments

Returns a new instance of GeneratePrintableArguments.

Parameters:

  • arguments (ConvenientService::RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Arguments)


39
40
41
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 39

def initialize(arguments:)
  @arguments = arguments
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



19
20
21
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 19

def arguments
  @arguments
end

Instance Method Details

#argsArray

Returns:

  • (Array)


24
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 24

delegate :args, to: :arguments

#blockProc

Returns:

  • (Proc)


34
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 34

delegate :block, to: :arguments

#callString

Returns:

  • (String)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 46

def call
  return "" if arguments.null_arguments?

  text =
    if args.any? && kwargs.any?
      "(#{printable_args}, #{printable_kwargs})"
    elsif args.any?
      "(#{printable_args})"
    elsif kwargs.any?
      "(#{printable_kwargs})"
    else
      "()"
    end

  text += " #{printable_block}" if block

  text
end

#kwargsHash

Returns:

  • (Hash)


29
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 29

delegate :kwargs, to: :arguments

#printable_argsString

Returns:

  • (String)


68
69
70
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 68

def printable_args
  args.map(&:inspect).join(", ")
end

#printable_blockString

Returns:

  • (String)


82
83
84
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 82

def printable_block
  block ? Utils::Proc.display(block) : ""
end

#printable_kwargsString

Returns:

  • (String)


75
76
77
# File 'lib/convenient_service/rspec/primitive_matchers/classes/delegate_to/entities/sub_matchers/arguments/commands/generate_printable_arguments.rb', line 75

def printable_kwargs
  kwargs.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
end