Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/24point/string.rb
Instance Method Summary collapse
-
#expression? ⇒ Boolean
match as ((3+5)*6)/2) (3*8)+(1-1) => true.
- #is_num? ⇒ Boolean
Instance Method Details
#expression? ⇒ Boolean
match as ((3+5)*6)/2) (3*8)+(1-1) => true
4 5 6 |
# File 'lib/24point/string.rb', line 4 def expression? !(self =~ /(?<expression>\((?<left>(\g<expression>|\d*))(?<operate>[\+\-\*\/])(?<right>(\g<expression>|\d*))\))/).nil? end |
#is_num? ⇒ Boolean
8 9 10 |
# File 'lib/24point/string.rb', line 8 def is_num? !(self =~ /^\d*$/).nil? end |