Sha256: 06194c42ec9bf24adad45a5a4ecc932dd8f9b511626f326e347f61cc0f65c80a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Gnip
  class Url < Gnip::Message
    attr_reader :url, :expanded_url, :expanded_status, :display_url, :indices, :expanded_url_title, :expanded_url_description

    def initialize params={}
      @url = params['url']
      @expanded_url = params['expanded_url']
      @display_url = params['display_url']
      @expanded_status = params['expanded_status']
      @indices = params['indices']
      @expanded_url_title = params['expanded_url_title']
      @expanded_url_description = params['expanded_url_description']
    end

    def url
      Addressable::URI.parse(@url) unless @url.nil?
    end
    
    def expanded_url
      Addressable::URI.parse(@expanded_url) unless @expanded_url.nil?
    end

    def original_attributes
      {
        :url => @url,
        :title => @title,
        :display_url => @display_url,
        :expanded_url => @expanded_url,
        :expanded_status => @expanded_status,
        :indices => @indices
      }.delete_if{|k,v| v.nil?}
    end

    def to_json
      generate_json(original_attributes)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gnip_api-1.0.1 lib/gnip_api/gnip/url.rb
gnip_api-1.0.0 lib/gnip_api/gnip/url.rb