Class: Blog::Author
- Inherits:
-
Object
- Object
- Blog::Author
- Defined in:
- lib/nexmo_developer/app/models/blog/author.rb
Constant Summary collapse
- DEFAULT_AVATAR =
'https://s3.eu-west-1.amazonaws.com/developer.vonage.com/vonage-logo-images/vonage-square-logo.png'.freeze
Instance Attribute Summary collapse
-
#alumni ⇒ Object
readonly
Returns the value of attribute alumni.
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#bio ⇒ Object
readonly
Returns the value of attribute bio.
-
#blogposts ⇒ Object
readonly
Returns the value of attribute blogposts.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#facebook_url ⇒ Object
readonly
Returns the value of attribute facebook_url.
-
#github_url ⇒ Object
readonly
Returns the value of attribute github_url.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#linkedin_url ⇒ Object
readonly
Returns the value of attribute linkedin_url.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#noteworthy ⇒ Object
readonly
Returns the value of attribute noteworthy.
-
#short_name ⇒ Object
readonly
Returns the value of attribute short_name.
-
#spotlight ⇒ Object
readonly
Returns the value of attribute spotlight.
-
#stackoverflow_url ⇒ Object
readonly
Returns the value of attribute stackoverflow_url.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#twitch_url ⇒ Object
readonly
Returns the value of attribute twitch_url.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#website_url ⇒ Object
readonly
Returns the value of attribute website_url.
-
#youtube_url ⇒ Object
readonly
Returns the value of attribute youtube_url.
Instance Method Summary collapse
- #build_all_blogposts_from_author(blogposts_json) ⇒ Object
- #build_avatar_url ⇒ Object
-
#initialize(attributes = {}) ⇒ Author
constructor
A new instance of Author.
Constructor Details
#initialize(attributes = {}) ⇒ Author
Returns a new instance of Author.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 9 def initialize(attributes = {}) @name = attributes['name'] || 'Vonage Team Member' @title = attributes['title'] || 'Vonage Team Member' @bio = attributes['bio'] || '' @short_name = attributes['short_name'] || 'vonage_team_member' @email = attributes['email'] || '' @image_url = attributes['image_url'] || '' @author = attributes['author'] || '' @alumni = attributes['alumni'] || false @team = attributes['team'] || false @hidden = attributes['hidden'] || false @spotlight = attributes['spotlight'] || false @noteworthy = attributes['noteworthy'] || '' @website_url = attributes['website_url'] || '' @twitter = attributes['twitter'] || '' @linkedin_url = attributes['linkedin_url'] || '' @github_url = attributes['github_url'] || '' @youtube_url = attributes['youtube_url'] || '' @facebook_url = attributes['facebook_url'] || '' @twitch_url = attributes['twitch_url'] || '' @stackoverflow_url = attributes['stackoverflow_url'] || '' @blogposts = [] @url = build_avatar_url end |
Instance Attribute Details
#alumni ⇒ Object (readonly)
Returns the value of attribute alumni.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def alumni @alumni end |
#author ⇒ Object (readonly)
Returns the value of attribute author.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def @author end |
#bio ⇒ Object (readonly)
Returns the value of attribute bio.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def bio @bio end |
#blogposts ⇒ Object (readonly)
Returns the value of attribute blogposts.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def blogposts @blogposts end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def email @email end |
#facebook_url ⇒ Object (readonly)
Returns the value of attribute facebook_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def facebook_url @facebook_url end |
#github_url ⇒ Object (readonly)
Returns the value of attribute github_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def github_url @github_url end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def hidden @hidden end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def image_url @image_url end |
#linkedin_url ⇒ Object (readonly)
Returns the value of attribute linkedin_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def linkedin_url @linkedin_url end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def name @name end |
#noteworthy ⇒ Object (readonly)
Returns the value of attribute noteworthy.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def noteworthy @noteworthy end |
#short_name ⇒ Object (readonly)
Returns the value of attribute short_name.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def short_name @short_name end |
#spotlight ⇒ Object (readonly)
Returns the value of attribute spotlight.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def spotlight @spotlight end |
#stackoverflow_url ⇒ Object (readonly)
Returns the value of attribute stackoverflow_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def stackoverflow_url @stackoverflow_url end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def team @team end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def title @title end |
#twitch_url ⇒ Object (readonly)
Returns the value of attribute twitch_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def twitch_url @twitch_url end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def twitter @twitter end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def url @url end |
#website_url ⇒ Object (readonly)
Returns the value of attribute website_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def website_url @website_url end |
#youtube_url ⇒ Object (readonly)
Returns the value of attribute youtube_url.
2 3 4 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 2 def youtube_url @youtube_url end |
Instance Method Details
#build_all_blogposts_from_author(blogposts_json) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 37 def (blogposts_json) # TODO: How to handle authors with no Json info? (assay-and-roy) @blogposts = blogposts_json.select do |b| if b['author'] && b['author']['short_name'].present? b['author']['short_name'].downcase == @short_name.downcase end end @blogposts = @blogposts.map { |b| Blog::Blogpost.new b } self end |
#build_avatar_url ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/nexmo_developer/app/models/blog/author.rb', line 50 def build_avatar_url return DEFAULT_AVATAR if image_url.blank? if image_url.include?('gravatar') || image_url.include?('https://github.com/') || image_url.include?('https://ca.slack-edge.com/') image_url else "#{Blog::Blogpost::CLOUDFRONT_BLOG_URL}authors/#{image_url.gsub('/content/images/', '')}" end end |