Class: CommandParser

Inherits:
Object
  • Object
show all
Defined in:
lib/command_parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ CommandParser

Returns a new instance of CommandParser.



2
3
4
# File 'lib/command_parser.rb', line 2

def initialize(text)
  @text = text
end

Instance Method Details

#parseObject

Takes text and turns it into a Ruby statement that can be passed to instance_eval on the appropriate object.



8
9
10
11
# File 'lib/command_parser.rb', line 8

def parse
  quote_urls
  @text 
end

#quote_urlsObject

Put quotes around unquoted urls



14
15
16
# File 'lib/command_parser.rb', line 14

def quote_urls
  @text.gsub!(/([\s(])(http:[^\s)]*)/, '\1\'\2\'')
end