Sha256: 12a4d5e2229a36cf9d394d9f1e8346245622ef0bd54570d8cf8acb3d136f32bb

Contents?: true

Size: 862 Bytes

Versions: 6

Compression:

Stored size: 862 Bytes

Contents

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

    def initialize params={}
      @url = params['url']
      @expanded_url = params['expanded_url']
      @display_url = params['display_url']
      @expanded_status = params['expanded_status']
      @indices = params['indices']
    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,
        :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

6 entries across 6 versions & 1 rubygems

Version Path
gnip_api-0.0.9 lib/gnip_api/gnip/url.rb
gnip_api-0.0.8 lib/gnip_api/gnip/url.rb
gnip_api-0.0.7 lib/gnip_api/gnip/url.rb
gnip_api-0.0.6 lib/gnip_api/gnip/url.rb
gnip_api-0.0.5 lib/gnip_api/gnip/url.rb
gnip_api-0.0.4 lib/gnip_api/gnip/url.rb