Class: Twingly::Search::Post
- Inherits:
-
Object
- Object
- Twingly::Search::Post
- Defined in:
- lib/twingly/search/post.rb
Overview
A blog post
Constant Summary collapse
- EMPTY_ARRAY =
[].freeze
- EMPTY_HASH =
{}.freeze
Instance Attribute Summary collapse
-
#author ⇒ String
readonly
the author of the blog post.
-
#authority ⇒ Integer
readonly
the blog’s authority/influence.
-
#blog_id ⇒ String
readonly
the blog ID (Twingly internal identification).
-
#blog_name ⇒ String
readonly
the name of the blog.
-
#blog_rank ⇒ Integer
readonly
the rank of the blog, based on authority and language.
-
#blog_url ⇒ String
readonly
the blog URL.
-
#coordinates ⇒ Hash
readonly
a hash containing :latitude and :longitude from the post RSS.
-
#id ⇒ String
readonly
the post ID (Twingly internal identification).
-
#images ⇒ Array
readonly
image URLs from the post (currently not populated).
-
#indexed_at ⇒ Time
readonly
the time, in UTC, when the post was indexed by Twingly.
-
#inlinks_count ⇒ String
readonly
number of links to this post that was found in other blog posts.
-
#language_code ⇒ String
readonly
ISO two letter language code for the language that the post was written in.
-
#links ⇒ Array
readonly
all links from the blog post to other resources.
-
#location_code ⇒ String
readonly
ISO two letter country code for the location of the blog.
-
#published_at ⇒ Time
readonly
the time, in UTC, when the post was published.
-
#reindexed_at ⇒ Time
readonly
timestamp when the post last was changed in our database/index.
-
#tags ⇒ Array
readonly
the post tags/categories.
-
#text ⇒ String
readonly
the blog post text.
-
#title ⇒ String
readonly
the post title.
-
#url ⇒ String
readonly
the post URL.
Instance Method Summary collapse
-
#indexed ⇒ Object
deprecated
Deprecated.
Please use #indexed_at instead
-
#outlinks ⇒ Object
deprecated
Deprecated.
Please use #links instead
-
#published ⇒ Object
deprecated
Deprecated.
Please use #published_at instead
-
#set_values(params) ⇒ Object
Sets all instance variables for the Post, given a Hash.
-
#summary ⇒ Object
deprecated
Deprecated.
Please use #text instead
-
#to_h ⇒ Hash
A hash containing all post attributes.
Instance Attribute Details
#author ⇒ String (readonly)
the author of the blog post
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def @author end |
#authority ⇒ Integer (readonly)
the blog’s authority/influence. See developer.twingly.com/resources/ranking/#authority
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def @authority end |
#blog_id ⇒ String (readonly)
the blog ID (Twingly internal identification)
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def blog_id @blog_id end |
#blog_name ⇒ String (readonly)
the name of the blog
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def blog_name @blog_name end |
#blog_rank ⇒ Integer (readonly)
the rank of the blog, based on authority and language. See developer.twingly.com/resources/ranking/#blogrank
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def blog_rank @blog_rank end |
#blog_url ⇒ String (readonly)
the blog URL
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def blog_url @blog_url end |
#coordinates ⇒ Hash (readonly)
a hash containing :latitude and :longitude from the post RSS
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def coordinates @coordinates end |
#id ⇒ String (readonly)
the post ID (Twingly internal identification)
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def id @id end |
#images ⇒ Array (readonly)
image URLs from the post (currently not populated)
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def images @images end |
#indexed_at ⇒ Time (readonly)
the time, in UTC, when the post was indexed by Twingly
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def indexed_at @indexed_at end |
#inlinks_count ⇒ String (readonly)
number of links to this post that was found in other blog posts
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def inlinks_count @inlinks_count end |
#language_code ⇒ String (readonly)
ISO two letter language code for the language that the post was written in
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def language_code @language_code end |
#links ⇒ Array (readonly)
all links from the blog post to other resources
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def links @links end |
#location_code ⇒ String (readonly)
ISO two letter country code for the location of the blog
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def location_code @location_code end |
#published_at ⇒ Time (readonly)
the time, in UTC, when the post was published
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def published_at @published_at end |
#reindexed_at ⇒ Time (readonly)
timestamp when the post last was changed in our database/index
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def reindexed_at @reindexed_at end |
#tags ⇒ Array (readonly)
the post tags/categories
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def @tags end |
#text ⇒ String (readonly)
the blog post text
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def text @text end |
#title ⇒ String (readonly)
the post title
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def title @title end |
#url ⇒ String (readonly)
the post URL
33 34 35 |
# File 'lib/twingly/search/post.rb', line 33 def url @url end |
Instance Method Details
#indexed ⇒ Object
Please use #indexed_at instead
75 76 77 78 |
# File 'lib/twingly/search/post.rb', line 75 def indexed warn "[DEPRECATION] `indexed` is deprecated. Please use `indexed_at` instead." indexed_at end |
#outlinks ⇒ Object
Please use #links instead
87 88 89 90 |
# File 'lib/twingly/search/post.rb', line 87 def outlinks warn "[DEPRECATION] `outlinks` is deprecated. Please use `links` instead." links end |
#published ⇒ Object
Please use #published_at instead
81 82 83 84 |
# File 'lib/twingly/search/post.rb', line 81 def published warn "[DEPRECATION] `published` is deprecated. Please use `published_at` instead." published_at end |
#set_values(params) ⇒ Object
Sets all instance variables for the Twingly::Search::Post, given a Hash.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/twingly/search/post.rb', line 45 def set_values(params) @id = params.fetch('id') @author = params.fetch('author') @url = params.fetch('url') @title = params.fetch('title') @text = params.fetch('text') @language_code = params.fetch('languageCode') @location_code = params.fetch('locationCode') @coordinates = params.fetch('coordinates') { EMPTY_HASH } @links = params.fetch('links') { EMPTY_ARRAY } @tags = params.fetch('tags') { EMPTY_ARRAY } @images = params.fetch('images') { EMPTY_ARRAY } @indexed_at = Time.parse(params.fetch('indexedAt')) @published_at = Time.parse(params.fetch('publishedAt')) @reindexed_at = Time.parse(params.fetch('reindexedAt')) @inlinks_count = params.fetch('inlinksCount').to_i @blog_id = params.fetch('blogId') @blog_name = params.fetch('blogName') @blog_url = params.fetch('blogUrl') @blog_rank = params.fetch('blogRank').to_i @authority = params.fetch('authority').to_i end |
#summary ⇒ Object
Please use #text instead
69 70 71 72 |
# File 'lib/twingly/search/post.rb', line 69 def summary warn "[DEPRECATION] `summary` is deprecated. Please use `text` instead." text end |
#to_h ⇒ Hash
Returns a hash containing all post attributes.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/twingly/search/post.rb', line 93 def to_h { id: @id, author: @author, url: @url, title: @title, text: @text, language_code: @language_code, location_code: @location_code, coordinates: @coordinates, links: @links, tags: @tags, images: @images, indexed_at: @indexed_at, published_at: @published_at, reindexed_at: @reindexed_at, inlinks_count: @inlinks_count, blog_id: @blog_id, blog_name: @blog_name, blog_url: @blog_url, blog_rank: @blog_rank, authority: @authority, } end |