Sha256: 94866a12c213db16b8bf9bac780ab038d7088a4d31e6f6922d5cd6e046dc6d35

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

require 'uri'

module Textp
  class 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")

    def initialize(text)
      @text = text
    end

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

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
textp-0.1.0 lib/textp/parser.rb