Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/24point/string.rb

Instance Method Summary collapse

Instance Method Details

#expression?Boolean

match as ((3+5)*6)/2) (3*8)+(1-1) => true

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


8
9
10
# File 'lib/24point/string.rb', line 8

def is_num?
	!(self =~ /^\d*$/).nil?
end