Class: Peachy::MethodName
- Inherits:
-
Object
- Object
- Peachy::MethodName
- Includes:
- StringStyler
- Defined in:
- lib/peachy/method_name.rb
Instance Method Summary collapse
- #as_xpath ⇒ Object
-
#check_for_convention ⇒ Object
Checks whether the method name is in the accepted convention, raising a MethodNotInRubyConvention if it’s not.
-
#initialize(method_name) ⇒ MethodName
constructor
A new instance of MethodName.
-
#variations ⇒ Object
Returns an array of distinct valid variations in the method name.
Methods included from StringStyler::Stripper
Constructor Details
#initialize(method_name) ⇒ MethodName
Returns a new instance of MethodName.
7 8 9 |
# File 'lib/peachy/method_name.rb', line 7 def initialize method_name @method_name = method_name.to_s end |
Instance Method Details
#as_xpath ⇒ Object
18 19 20 |
# File 'lib/peachy/method_name.rb', line 18 def as_xpath variations.map {|variation| "./#{variation}" } * '|' end |
#check_for_convention ⇒ Object
Checks whether the method name is in the accepted convention, raising a MethodNotInRubyConvention if it’s not. This check does not allow method names to have question marks, exclamation marks or numbers, however.
25 26 27 |
# File 'lib/peachy/method_name.rb', line 25 def check_for_convention raise MethodNotInRubyConvention.new(self) unless matches_convention? end |
#variations ⇒ Object
Returns an array of distinct valid variations in the method name. The valid varations are the underlying method name, plus all variations provided by methods defined in the StringStyler module.
14 15 16 |
# File 'lib/peachy/method_name.rb', line 14 def variations variation_methods.inject([]) {|array, method| array << send(method)}.uniq end |