Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created August 25, 2016 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/718c008d525f93f8d8826b8dcf3fda40 to your computer and use it in GitHub Desktop.
Save havenwood/718c008d525f93f8d8826b8dcf3fda40 to your computer and use it in GitHub Desktop.
Rubular-like spike
class Rubula
attr_accessor :test_string
def initialize test_string
@test_string = test_string
end
def match regexp
@test_string.match regexp
end
def match_results regexp
match_data = match regexp
puts "#{match_data.pre_match}\e[7m#{match_data[0]}\e[27m#{match_data.post_match}"
end
end
demo = Rubula.new 'cschneid_'
demo.match_results /s\w{3}/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment