Class: Textp::Parser
- Inherits:
-
Object
- Object
- Textp::Parser
- Defined in:
- lib/textp/parser.rb
Instance Method Summary collapse
- #has_links? ⇒ Boolean
-
#initialize(text) ⇒ Parser
constructor
Pass in some text and all things that can be parsed will be parsed and seperated into individual parts.
- #links ⇒ Object
- #parse ⇒ Object
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
22 23 24 25 |
# File 'lib/textp/parser.rb', line 22 def has_links? urls = URI.extract(@text) (urls.empty?) ? false : true end |
#links ⇒ Object
27 28 29 30 |
# File 'lib/textp/parser.rb', line 27 def links links = URI.extract(@text) links end |
#parse ⇒ Object
18 19 20 |
# File 'lib/textp/parser.rb', line 18 def parse (!@text.nil?) ? @text : nil end |