Class: ActiveDoc::Descriptions::MethodArgumentDescription::RegexpArgumentExpectation

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) ⇒ RegexpArgumentExpectation

Returns a new instance of RegexpArgumentExpectation.



156
157
158
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 156

def initialize(argument)
  @regexp = argument
end

Class Method Details

.from(argument, options, proc) ⇒ Object



174
175
176
177
178
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 174

def self.from(argument, options, proc)
  if argument.is_a? Regexp
    self.new(argument)
  end
end

Instance Method Details

#condition?(value, args_with_vals) ⇒ Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 160

def condition?(value, args_with_vals)
  value =~ @regexp
end

#expectation_fail_to_sObject

Expected to… NOTE: Possible thread-safe problem



166
167
168
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 166

def expectation_fail_to_s
  "match #{@regexp}, got '#{@failed_value.inspect}'"
end

#to_rdocObject



170
171
172
# File 'lib/active_doc/descriptions/method_argument_description.rb', line 170

def to_rdoc
  @regexp.inspect.gsub('\\') { '\\\\' }
end