Class: Twingly::LiveFeed::Post
- Inherits:
-
Object
- Object
- Twingly::LiveFeed::Post
- Defined in:
- lib/twingly/livefeed/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
-
#set_values(params) ⇒ Object
Sets all instance variables for the Post, given a Hash.
-
#to_h ⇒ Hash
A hash containing all post attributes.
Instance Attribute Details
#author ⇒ String (readonly)
the author of the blog post
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def @author end |
#authority ⇒ Integer (readonly)
the blog’s authority/influence. See developer.twingly.com/resources/ranking/#authority
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def @authority end |
#blog_id ⇒ String (readonly)
the blog ID (Twingly internal identification)
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def blog_id @blog_id end |
#blog_name ⇒ String (readonly)
the name of the blog
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 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
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def blog_rank @blog_rank end |
#blog_url ⇒ String (readonly)
the blog URL
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def blog_url @blog_url end |
#coordinates ⇒ Hash (readonly)
a hash containing :latitude and :longitude from the post RSS
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def coordinates @coordinates end |
#id ⇒ String (readonly)
the post ID (Twingly internal identification)
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def id @id end |
#images ⇒ Array (readonly)
image URLs from the post (currently not populated)
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def images @images end |
#indexed_at ⇒ Time (readonly)
the time, in UTC, when the post was indexed by Twingly
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def indexed_at @indexed_at end |
#inlinks_count ⇒ String (readonly)
number of links to this post that was found in other blog posts
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def inlinks_count @inlinks_count end |
#language_code ⇒ String (readonly)
ISO two letter language code for the language that the post was written in
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def language_code @language_code end |
#links ⇒ Array (readonly)
all links from the blog post to other resources
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def links @links end |
#location_code ⇒ String (readonly)
ISO two letter country code for the location of the blog
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def location_code @location_code end |
#published_at ⇒ Time (readonly)
the time, in UTC, when the post was published
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def published_at @published_at end |
#reindexed_at ⇒ Time (readonly)
timestamp when the post last was changed in our database/index
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def reindexed_at @reindexed_at end |
#tags ⇒ Array (readonly)
the post tags/categories
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def @tags end |
#text ⇒ String (readonly)
the blog post text
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def text @text end |
#title ⇒ String (readonly)
the post title
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def title @title end |
#url ⇒ String (readonly)
the post URL
34 35 36 |
# File 'lib/twingly/livefeed/post.rb', line 34 def url @url end |
Instance Method Details
#set_values(params) ⇒ Object
Sets all instance variables for the Twingly::LiveFeed::Post, given a Hash.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/twingly/livefeed/post.rb', line 46 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 |
#to_h ⇒ Hash
Returns a hash containing all post attributes.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/twingly/livefeed/post.rb', line 70 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 |