Class: FetchUtil::Result
- Inherits:
-
Object
- Object
- FetchUtil::Result
- Defined in:
- lib/fetch_util/result.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#area_sqft ⇒ Object
readonly
Returns the value of attribute area_sqft.
-
#bathrooms ⇒ Object
readonly
Returns the value of attribute bathrooms.
-
#bedrooms ⇒ Object
readonly
Returns the value of attribute bedrooms.
-
#byline ⇒ Object
readonly
Returns the value of attribute byline.
-
#canonical_url ⇒ Object
readonly
Returns the value of attribute canonical_url.
-
#community ⇒ Object
readonly
Returns the value of attribute community.
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#content_completeness_ratio ⇒ Object
readonly
Returns the value of attribute content_completeness_ratio.
-
#content_format ⇒ Object
readonly
Returns the value of attribute content_format.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#excerpt ⇒ Object
readonly
Returns the value of attribute excerpt.
-
#final_url ⇒ Object
readonly
Returns the value of attribute final_url.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#ingredients ⇒ Object
readonly
Returns the value of attribute ingredients.
-
#instructions ⇒ Object
readonly
Returns the value of attribute instructions.
-
#language ⇒ Object
readonly
Returns the value of attribute language.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#markdown ⇒ Object
readonly
Returns the value of attribute markdown.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#paywall_state ⇒ Object
readonly
Returns the value of attribute paywall_state.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#published_time ⇒ Object
readonly
Returns the value of attribute published_time.
-
#rating ⇒ Object
readonly
Returns the value of attribute rating.
-
#reader_mode ⇒ Object
readonly
Returns the value of attribute reader_mode.
-
#reply_count ⇒ Object
readonly
Returns the value of attribute reply_count.
-
#score ⇒ Object
readonly
Returns the value of attribute score.
-
#site_name ⇒ Object
readonly
Returns the value of attribute site_name.
-
#social_kind ⇒ Object
readonly
Returns the value of attribute social_kind.
-
#suspect ⇒ Object
readonly
Returns the value of attribute suspect.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Class Method Summary collapse
- .error(url:, warning:, message:) ⇒ Object
- .from_payload(url:, final_url:, payload:, canonical_url:, content_type:, warnings:, suspect:) ⇒ Object
Instance Method Summary collapse
-
#initialize(url:, final_url:, title:, byline:, excerpt:, site_name:, published_time:, canonical_url:, language:, name:, company:, location:, description:, ingredients:, instructions:, bedrooms:, bathrooms:, area_sqft:, html:, markdown:, metadata:, reader_mode:, content_type:, suspect:, warnings:, content_completeness_ratio: 1.0, content_format: nil, paywall_state: nil, price: nil, rating: nil, address: nil, social_kind: nil, platform: nil, handle: nil, reply_count: nil, community: nil, score: nil, error_message: nil) ⇒ Result
constructor
A new instance of Result.
- #to_h ⇒ Object
Constructor Details
#initialize(url:, final_url:, title:, byline:, excerpt:, site_name:, published_time:, canonical_url:, language:, name:, company:, location:, description:, ingredients:, instructions:, bedrooms:, bathrooms:, area_sqft:, html:, markdown:, metadata:, reader_mode:, content_type:, suspect:, warnings:, content_completeness_ratio: 1.0, content_format: nil, paywall_state: nil, price: nil, rating: nil, address: nil, social_kind: nil, platform: nil, handle: nil, reply_count: nil, community: nil, score: nil, error_message: nil) ⇒ Result
Returns a new instance of Result.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/fetch_util/result.rb', line 180 def initialize(url:, final_url:, title:, byline:, excerpt:, site_name:, published_time:, canonical_url:, language:, name:, company:, location:, description:, ingredients:, instructions:, bedrooms:, bathrooms:, area_sqft:, html:, markdown:, metadata:, reader_mode:, content_type:, suspect:, warnings:, content_completeness_ratio: 1.0, content_format: nil, paywall_state: nil, price: nil, rating: nil, address: nil, social_kind: nil, platform: nil, handle: nil, reply_count: nil, community: nil, score: nil, error_message: nil) @url = url @final_url = final_url @title = title @byline = @excerpt = excerpt @site_name = site_name @published_time = published_time @canonical_url = canonical_url @language = language @name = name @company = company @location = location @description = description @ingredients = ingredients @instructions = instructions @bedrooms = bedrooms @bathrooms = bathrooms @area_sqft = area_sqft @html = html @markdown = markdown @metadata = .freeze @reader_mode = reader_mode @content_type = content_type @suspect = suspect @warnings = warnings.freeze @content_completeness_ratio = content_completeness_ratio @content_format = content_format&.freeze @paywall_state = paywall_state&.freeze @price = price @rating = @address = address @social_kind = @platform = platform @handle = handle @reply_count = reply_count @community = community @score = score @error_message = end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def address @address end |
#area_sqft ⇒ Object (readonly)
Returns the value of attribute area_sqft.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def area_sqft @area_sqft end |
#bathrooms ⇒ Object (readonly)
Returns the value of attribute bathrooms.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def bathrooms @bathrooms end |
#bedrooms ⇒ Object (readonly)
Returns the value of attribute bedrooms.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def bedrooms @bedrooms end |
#byline ⇒ Object (readonly)
Returns the value of attribute byline.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def @byline end |
#canonical_url ⇒ Object (readonly)
Returns the value of attribute canonical_url.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def canonical_url @canonical_url end |
#community ⇒ Object (readonly)
Returns the value of attribute community.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def community @community end |
#company ⇒ Object (readonly)
Returns the value of attribute company.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def company @company end |
#content_completeness_ratio ⇒ Object (readonly)
Returns the value of attribute content_completeness_ratio.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def content_completeness_ratio @content_completeness_ratio end |
#content_format ⇒ Object (readonly)
Returns the value of attribute content_format.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def content_format @content_format end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def content_type @content_type end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def description @description end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def @error_message end |
#excerpt ⇒ Object (readonly)
Returns the value of attribute excerpt.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def excerpt @excerpt end |
#final_url ⇒ Object (readonly)
Returns the value of attribute final_url.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def final_url @final_url end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def handle @handle end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def html @html end |
#ingredients ⇒ Object (readonly)
Returns the value of attribute ingredients.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def ingredients @ingredients end |
#instructions ⇒ Object (readonly)
Returns the value of attribute instructions.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def instructions @instructions end |
#language ⇒ Object (readonly)
Returns the value of attribute language.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def language @language end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def location @location end |
#markdown ⇒ Object (readonly)
Returns the value of attribute markdown.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def markdown @markdown end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def @metadata end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def name @name end |
#paywall_state ⇒ Object (readonly)
Returns the value of attribute paywall_state.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def paywall_state @paywall_state end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def platform @platform end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def price @price end |
#published_time ⇒ Object (readonly)
Returns the value of attribute published_time.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def published_time @published_time end |
#rating ⇒ Object (readonly)
Returns the value of attribute rating.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def @rating end |
#reader_mode ⇒ Object (readonly)
Returns the value of attribute reader_mode.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def reader_mode @reader_mode end |
#reply_count ⇒ Object (readonly)
Returns the value of attribute reply_count.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def reply_count @reply_count end |
#score ⇒ Object (readonly)
Returns the value of attribute score.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def score @score end |
#site_name ⇒ Object (readonly)
Returns the value of attribute site_name.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def site_name @site_name end |
#social_kind ⇒ Object (readonly)
Returns the value of attribute social_kind.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def @social_kind end |
#suspect ⇒ Object (readonly)
Returns the value of attribute suspect.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def suspect @suspect end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def title @title end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def url @url end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
5 6 7 |
# File 'lib/fetch_util/result.rb', line 5 def warnings @warnings end |
Class Method Details
.error(url:, warning:, message:) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/fetch_util/result.rb', line 90 def error(url:, warning:, message:) = { content_url: url, content_type: "error", suspect: true, warnings: [warning], error_message: , social_kind: nil, platform: nil, handle: nil, reply_count: nil, community: nil, score: nil }.freeze new( url: url, final_url: url, title: nil, byline: nil, excerpt: nil, site_name: nil, published_time: nil, canonical_url: nil, language: nil, name: nil, company: nil, location: nil, description: nil, ingredients: nil, instructions: nil, bedrooms: nil, bathrooms: nil, area_sqft: nil, html: nil, markdown: "", metadata: , reader_mode: nil, content_type: "error", suspect: true, warnings: [warning], error_message: ) end |
.from_payload(url:, final_url:, payload:, canonical_url:, content_type:, warnings:, suspect:) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fetch_util/result.rb', line 15 def from_payload(url:, final_url:, payload:, canonical_url:, content_type:, warnings:, suspect:) content_completeness_ratio = payload["contentCompletenessRatio"]&.to_f || 1.0 content_format = payload["contentFormat"] paywall_state = payload["paywallState"] = ( payload, canonical_url: canonical_url, final_url: final_url, content_type: content_type, suspect: suspect, warnings: warnings, content_completeness_ratio: content_completeness_ratio, content_format: content_format, paywall_state: paywall_state, name: payload["name"], company: payload["company"], location: payload["location"], description: payload["description"], ingredients: payload["ingredients"], instructions: payload["instructions"], bedrooms: payload["bedrooms"], bathrooms: payload["bathrooms"], area_sqft: payload["areaSqft"], price: payload["price"], rating: payload["rating"], address: payload["address"], social_kind: payload["socialKind"], platform: payload["platform"], handle: payload["handle"], reply_count: payload["replyCount"], community: payload["community"], score: payload["score"] ) new( url: url, final_url: final_url, title: payload["title"], byline: payload["byline"], excerpt: payload["excerpt"], site_name: payload["siteName"], published_time: payload["publishedTime"], canonical_url: canonical_url, language: payload["language"], name: payload["name"], company: payload["company"], location: payload["location"], description: payload["description"], ingredients: payload["ingredients"], instructions: payload["instructions"], bedrooms: payload["bedrooms"], bathrooms: payload["bathrooms"], area_sqft: payload["areaSqft"], html: payload["html"], markdown: payload["markdown"], metadata: , reader_mode: payload["readerMode"], content_type: content_type, suspect: suspect, warnings: warnings, content_completeness_ratio: content_completeness_ratio, content_format: content_format, paywall_state: paywall_state, price: payload["price"], rating: payload["rating"], address: payload["address"], social_kind: payload["socialKind"], platform: payload["platform"], handle: payload["handle"], reply_count: payload["replyCount"], community: payload["community"], score: payload["score"] ) end |
Instance Method Details
#to_h ⇒ Object
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/fetch_util/result.rb', line 227 def to_h { url: url, final_url: final_url, title: title, byline: , excerpt: excerpt, site_name: site_name, published_time: published_time, canonical_url: canonical_url, language: language, name: name, company: company, location: location, description: description, ingredients: ingredients, instructions: instructions, bedrooms: bedrooms, bathrooms: bathrooms, area_sqft: area_sqft, html: html, markdown: markdown, metadata: , reader_mode: reader_mode, content_type: content_type, suspect: suspect, warnings: warnings, content_completeness_ratio: content_completeness_ratio, content_format: content_format, paywall_state: paywall_state, price: price, rating: , address: address, social_kind: , platform: platform, handle: handle, reply_count: reply_count, community: community, score: score, error_message: } end |