Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#grab(rexp, opts = {}) ⇒ Object

Public: Grab content out of a string. Returns an array of each match.

rexp - Regexp to search with opts - String to search in Example:

method = grab /h/, from: "hello"
# => ['h']


9
10
11
12
# File 'lib/human_behavior.rb', line 9

def grab(rexp, opts={})
  str = opts[:from]
  str.scan(rexp)
end

#validate_that(rexp, opts = {}) ⇒ Object

rexp - Regexp to search with opts - String to search in Example:

validates_that /h/, is_inside: 'hello'
# => true


21
22
23
24
25
# File 'lib/human_behavior.rb', line 21

def validate_that(rexp, opts={})
  str = opts[:is_inside]
  conditional = rexp =~ str
  true unless conditional == nil
end