Class: Textp::Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Parser

Pass in some text and all things that can be parsed will be parsed and seperated into individual parts.

Usage:

> Parser.new(“Meeting tomorrow at 3:30 PM.”)

> Parser.new(“This embeded video is cool: youtube_link”)



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

def initialize(text)
  @text = text
end

Instance Method Details

#has_links?Boolean

Returns:

  • (Boolean)


22
23
24
25
# File 'lib/textp/parser.rb', line 22

def has_links?
  urls = URI.extract(@text)
  (urls.empty?) ? false : true
end


27
28
29
30
# File 'lib/textp/parser.rb', line 27

def links
  links = URI.extract(@text)
  links
end

#parseObject



18
19
20
# File 'lib/textp/parser.rb', line 18

def parse
  (!@text.nil?) ? @text : nil
end