lib/gnip_api/gnip/url.rb in gnip_api-1.0.1 vs lib/gnip_api/gnip/url.rb in gnip_api-1.0.2

- old
+ new

@@ -1,38 +1,32 @@ module Gnip class Url < Gnip::Message - attr_reader :url, :expanded_url, :expanded_status, :display_url, :indices, :expanded_url_title, :expanded_url_description + attr_reader :url, :expanded_url, :expanded_status, :display_url, :indices, :expanded_url_title, :expanded_url_description, :raw def initialize params={} + @raw = params @url = params['url'] - @expanded_url = params['expanded_url'] @display_url = params['display_url'] + @expanded_url = params['expanded_url'] @expanded_status = params['expanded_status'] - @indices = params['indices'] @expanded_url_title = params['expanded_url_title'] @expanded_url_description = params['expanded_url_description'] + @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 + def to_h { :url => @url, - :title => @title, :display_url => @display_url, :expanded_url => @expanded_url, :expanded_status => @expanded_status, + :expanded_url_title => @expanded_url_title, + :expanded_url_description => @expanded_url_description, :indices => @indices }.delete_if{|k,v| v.nil?} end def to_json - generate_json(original_attributes) + @raw.to_json end end end