Class: UrlShortener::Response::Info

Inherits:
UrlShortener::Response show all
Defined in:
lib/url_shortener/response/info.rb

Overview

All elements within doc are available as instance method calls. such as; info_response_instance.htmlMetaDescription or info_response_instance.htmlTitle if you don’t like using camelised method names then you can use underscores like info_response_instance.html_meta_description or info_response_instance.html_title and it should work fine

e.g. xml response <bitly>

<errorCode>0</errorCode>
<errorMessage/>
  <results>
    <doc>
      <urlFetched>http://www.cnn.com/</urlFetched>
      <shortenedByUser>bitly</shortenedByUser>
      <keywords/>
      <hash>31IqMl</hash>
      <exif/>
      <longUrl>http://cnn.com/</longUrl>
      <htmlMetaDescription>
        CNN.com delivers the latest breaking news and information on the latest top stories, weather, business, entertainment, politics, and more. For in-depth coverage, CNN.com provides special reports, video, audio, photo galleries, and interactive guides.
      </htmlMetaDescription>
      <indexed>1253643458</indexed>
      <htmlTitle>
        CNN.com - Breaking News, U.S., World, Weather, Entertainment &amp; Video News
      </htmlTitle>
      <htmlMetaKeywords>
        <item>CNN</item>
        <item>CNN news</item>
        <item>CNN.com</item>
        <item>CNN TV</item>
        <item>news</item>
      </htmlMetaKeywords>
      <mirrorUrl/>
      <keyword/>
      <contentLegth>99195.0</contentLegth>
    <fileExtension/>
  </doc>
</results>

<statusCode>OK</statusCode> </bitly>

Instance Attribute Summary

Attributes inherited from UrlShortener::Response

#attributes, #result

Instance Method Summary collapse

Methods inherited from UrlShortener::Response

#method_missing

Constructor Details

#initialize(response) ⇒ Info

Returns a new instance of Info.



45
46
47
# File 'lib/url_shortener/response/info.rb', line 45

def initialize(response)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class UrlShortener::Response

Instance Method Details

#hashObject

Just to override the hash method provided by hashie that adds some other hash value



51
52
53
54
# File 'lib/url_shortener/response/info.rb', line 51

def hash
  return unless doc_value?
  result['doc']['hash']
end