Class: Result
Overview
A struct which represents a search result. Will be documented much better soon.
Instance Attribute Summary collapse
-
#snippet ⇒ String
readonly
The snippet of the search result.
-
#title ⇒ String
readonly
The title of the search result.
-
#url ⇒ String
readonly
The URL of the search result.
Instance Method Summary collapse
-
#to_html ⇒ String
An HTML representation of the search result, to be rendered in the results page.
Instance Attribute Details
#snippet ⇒ String (readonly)
Returns the snippet of the search result.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/search_tools.rb', line 32 Result = Struct.new(:url, :title, :snippet) do # @return [String] An HTML representation of the search result, to be rendered in the results page. def to_html res = self mab do a(res.title, href: res.url) 2.times { br } text res.url 2.times { br } text res.snippet 2.times { br } end end end |
#title ⇒ String (readonly)
Returns the title of the search result.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/search_tools.rb', line 32 Result = Struct.new(:url, :title, :snippet) do # @return [String] An HTML representation of the search result, to be rendered in the results page. def to_html res = self mab do a(res.title, href: res.url) 2.times { br } text res.url 2.times { br } text res.snippet 2.times { br } end end end |
#url ⇒ String (readonly)
Returns the URL of the search result.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/search_tools.rb', line 32 Result = Struct.new(:url, :title, :snippet) do # @return [String] An HTML representation of the search result, to be rendered in the results page. def to_html res = self mab do a(res.title, href: res.url) 2.times { br } text res.url 2.times { br } text res.snippet 2.times { br } end end end |
Instance Method Details
#to_html ⇒ String
Returns An HTML representation of the search result, to be rendered in the results page.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/search_tools.rb', line 34 def to_html res = self mab do a(res.title, href: res.url) 2.times { br } text res.url 2.times { br } text res.snippet 2.times { br } end end |