Module: Mixin::Guess
- Included in:
- Shell
- Defined in:
- lib/clearbooks/interface/thor/mixin/guess.rb
Instance Method Summary collapse
-
#guess_version(string) ⇒ Object
“rake, version 10.1.1” -> 10.1.1.
- #initialize(*args) ⇒ Object
Instance Method Details
#guess_version(string) ⇒ Object
“rake, version 10.1.1”
-> 10.1.1
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/clearbooks/interface/thor/mixin/guess.rb', line 32 def guess_version string result = "" begin # Sanity raise ArgumentError, "Version has to be of type string" unless( string.is_a?( String ) ) raise ArgumentError, "Version can't be empty" if( string.empty? ) result = string.match( /\d+\.\d+\.\d+/ ).to_s # matches first only rescue Exception => e say "(EE) " + e., :red result = "" end return result end |
#initialize(*args) ⇒ Object
20 21 22 |
# File 'lib/clearbooks/interface/thor/mixin/guess.rb', line 20 def initialize *args super end |