Class: RSpec::ApiGen::Argument

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec-apigen/argument.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, accept_block = false) ⇒ Argument

Returns a new instance of Argument.



5
6
7
8
9
# File 'lib/rspec-apigen/argument.rb', line 5

def initialize(name, description, accept_block = false)
  @name = name
  @description = description
  @accept_block = accept_block
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/rspec-apigen/argument.rb', line 3

def description
  @description
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/rspec-apigen/argument.rb', line 3

def name
  @name
end

Class Method Details

.describe(args) ⇒ Object



32
33
34
# File 'lib/rspec-apigen/argument.rb', line 32

def self.describe(args)
  "(#{inspect_args(args).join(', ')})"
end

.inspect_args(args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rspec-apigen/argument.rb', line 19

def self.inspect_args(args)
  args.collect do |x|
    case x
      when Argument
        x.name
      when RSpec::Mocks::Mock
        x.instance_variable_get('@name')
      else
        "#{x}:#{x.class}"
    end
  end
end

Instance Method Details

#accept_block?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rspec-apigen/argument.rb', line 11

def accept_block?
  @accept_block      
end

#to_sObject



15
16
17
# File 'lib/rspec-apigen/argument.rb', line 15

def to_s
  "Arg #{name}"
end