Class: Speq::Arguments

Inherits:
Object
  • Object
show all
Defined in:
lib/speq/values.rb,
lib/speq/string_fmt.rb

Overview

Holds arguments to be passed to something later

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Arguments

Returns a new instance of Arguments.



63
64
65
66
# File 'lib/speq/values.rb', line 63

def initialize(*args, &block)
  @args = args
  @block = block if block_given?
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



62
63
64
# File 'lib/speq/values.rb', line 62

def args
  @args
end

#blockObject (readonly)

Returns the value of attribute block.



62
63
64
# File 'lib/speq/values.rb', line 62

def block
  @block
end

Instance Method Details

#to_sObject



64
65
66
67
68
69
# File 'lib/speq/string_fmt.rb', line 64

def to_s
  arg_str = args.map(&:inspect).join(', ')
  sep = args.empty? && block ? '' : ', '
  block_str = block ? "#{sep}&{ ... }" : ''
  "#{arg_str}#{block_str}"
end