Class: Geld::Utils::StringInquirer
- Inherits:
-
String
- Object
- String
- Geld::Utils::StringInquirer
- Defined in:
- lib/geld/utils/string_inquirer.rb
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments) ⇒ Object (private)
check environment and index
self => stg01 method_name => dev01?
> false
self => stg01 method_name => stg02?
> false
self => stg01 method_name => stg?
> true
self => stg01 method_name => stg01?
> true
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/geld/utils/string_inquirer.rb', line 26 def method_missing(method_name, *arguments) if method_name[-1] == '?' regexp = /\A(.[^0-9]+)([0-9]*)\z/ m1 = regexp.match(self) m2 = regexp.match(method_name[0..-2]) return false unless m1[1] == m2[1] return false if m1[2].length == 0 && m2[2].length > 0 return false if (m1[2].length > 0 && m2[2].length > 0) && (m1[2].to_s != m2[2].to_s) true else super end end |