Class: Google_search_cmdline::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/google_search_cmdline_result.rb

Overview

This class represents the results when executing Google_search_cmd#search, which is given by the enumerator.

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Result

Returns a new instance of Result.



3
4
5
6
7
8
# File 'lib/google_search_cmdline_result.rb', line 3

def initialize(args)
  @args = args
  
  raise "Invalid URL: '#{@args[:url]}'." if @args[:url].to_s.strip.empty?
  raise "Invalid title: '#{@args[:title]}'." if @args[:title].to_s.strip.empty?
end

Instance Method Details

#titleObject

Returns the title of the result.



11
12
13
# File 'lib/google_search_cmdline_result.rb', line 11

def title
  return @args[:title]
end

#urlObject

Returns the URL of the result.



16
17
18
# File 'lib/google_search_cmdline_result.rb', line 16

def url
  return @args[:url]
end