Class: ActiveDoc::Descriptions::MethodArgumentDescription::TypeArgumentExpectation

Inherits:
ArgumentExpectation
  • Object
show all
Defined in:
lib/active_doc/descriptions/method_argument_description.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ArgumentExpectation

#additional_rdoc, find, #fulfilled?, inherited

Constructor Details

#initialize(argument) ⇒ TypeArgumentExpectation

Returns a new instance of TypeArgumentExpectation.



131
132
133
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 131

def initialize(argument)
  @type = argument
end

Class Method Details

.from(argument, options, proc) ⇒ Object



148
149
150
151
152
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 148

def self.from(argument, options, proc)
  if argument.is_a?(Class) && proc.nil?
    self.new(argument)
  end
end

Instance Method Details

#condition?(value, args_with_vals) ⇒ Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 135

def condition?(value, args_with_vals)
  value.is_a? @type
end

#expectation_fail_to_sObject

Expected to…



140
141
142
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 140

def expectation_fail_to_s
  "be #{@type.name}, got #{@failed_value.class.name}"
end

#to_rdocObject



144
145
146
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 144

def to_rdoc
  @type.name
end