Class: Google::Search::Item
- Inherits:
-
Object
- Object
- Google::Search::Item
- Defined in:
- lib/google-search/item/web.rb,
lib/google-search/item/base.rb,
lib/google-search/item/blog.rb,
lib/google-search/item/book.rb,
lib/google-search/item/news.rb,
lib/google-search/item/image.rb,
lib/google-search/item/local.rb,
lib/google-search/item/video.rb,
lib/google-search/item/patent.rb
Defined Under Namespace
Classes: Blog, Book, Image, Local, News, Patent, Video, Web
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Contents.
-
#index ⇒ Object
readonly
Index.
-
#thumbnail_height ⇒ Object
readonly
Thumbnail height in pixels.
-
#thumbnail_uri ⇒ Object
readonly
Thumbnail uri.
-
#thumbnail_width ⇒ Object
readonly
Thumbnail width in pixels.
-
#title ⇒ Object
readonly
Unformatted page title.
-
#uri ⇒ Object
readonly
Absolute uri.
-
#visible_uri ⇒ Object
readonly
Visible uri.
Class Method Summary collapse
-
.class_for(google_class) ⇒ Object
Return class for google_class string formatted as ‘GwebSearch’, ‘GbookSearch’, etc.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Item
constructor
Initialize with hash.
Constructor Details
#initialize(hash) ⇒ Item
Initialize with hash.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/google-search/item/base.rb', line 49 def initialize hash @index = hash['index'] @title = hash['titleNoFormatting'] || hash['title'] @uri = hash['unescapedUrl'] || hash['url'] || hash['postUrl'] @content = hash['contentNoFormatting'] || hash['content'] @thumbnail_uri = hash['tbUrl'] @thumbnail_width = hash['tbWidth'].to_i @thumbnail_height = hash['tbHeight'].to_i @visible_uri = hash['visibleUrl'] end |
Instance Attribute Details
#content ⇒ Object (readonly)
Contents.
44 45 46 |
# File 'lib/google-search/item/base.rb', line 44 def content @content end |
#index ⇒ Object (readonly)
Index.
9 10 11 |
# File 'lib/google-search/item/base.rb', line 9 def index @index end |
#thumbnail_height ⇒ Object (readonly)
Thumbnail height in pixels.
39 40 41 |
# File 'lib/google-search/item/base.rb', line 39 def thumbnail_height @thumbnail_height end |
#thumbnail_uri ⇒ Object (readonly)
Thumbnail uri.
29 30 31 |
# File 'lib/google-search/item/base.rb', line 29 def thumbnail_uri @thumbnail_uri end |
#thumbnail_width ⇒ Object (readonly)
Thumbnail width in pixels.
34 35 36 |
# File 'lib/google-search/item/base.rb', line 34 def thumbnail_width @thumbnail_width end |
#title ⇒ Object (readonly)
Unformatted page title.
14 15 16 |
# File 'lib/google-search/item/base.rb', line 14 def title @title end |
#uri ⇒ Object (readonly)
Absolute uri.
19 20 21 |
# File 'lib/google-search/item/base.rb', line 19 def uri @uri end |
#visible_uri ⇒ Object (readonly)
Visible uri.
24 25 26 |
# File 'lib/google-search/item/base.rb', line 24 def visible_uri @visible_uri end |
Class Method Details
.class_for(google_class) ⇒ Object
Return class for google_class string formatted as ‘GwebSearch’, ‘GbookSearch’, etc.
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/google-search/item/base.rb', line 64 def self.class_for google_class case google_class when 'GwebSearch' ; Web when 'GlocalSearch' ; Local when 'GbookSearch' ; Book when 'GimageSearch' ; Image when 'GvideoSearch' ; Video when 'GpatentSearch' ; Patent when 'GnewsSearch' ; News when 'GblogSearch' ; Blog end end |