Class: Mbrao::Author
- Inherits:
-
Object
- Object
- Mbrao::Author
- Defined in:
- lib/mbrao/author.rb
Overview
Represents the author of a parsed content, with its metadata.
Instance Attribute Summary collapse
-
#email ⇒ String
The email of the author.
-
#image ⇒ String
The URL of the avatar of the author.
-
#metadata ⇒ HashWithIndifferentAccess
The full list of metadata of this author.
-
#name ⇒ String
The name of the author.
-
#uid ⇒ String
A unique ID for this post.
-
#website ⇒ String
The website of the author.
Class Method Summary collapse
-
.create(data) ⇒ Author
Creates an author from a
Hash.
Instance Method Summary collapse
-
#initialize(name, email = nil, website = nil, image = nil, metadata = nil, uid = nil) ⇒ Author
constructor
Creates a new author.
Constructor Details
#initialize(name, email = nil, website = nil, image = nil, metadata = nil, uid = nil) ⇒ Author
Creates a new author.
38 39 40 41 42 43 44 45 |
# File 'lib/mbrao/author.rb', line 38 def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end |
Instance Attribute Details
#email ⇒ String
Returns The email of the author.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
#image ⇒ String
Returns The URL of the avatar of the author.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
#metadata ⇒ HashWithIndifferentAccess
Returns The full list of metadata of this author.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
#name ⇒ String
Returns The name of the author.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
#uid ⇒ String
Returns A unique ID for this post. This is only for client uses.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
#website ⇒ String
Returns The website of the author.
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 |
# File 'lib/mbrao/author.rb', line 22 class Author attr_accessor :uid attr_accessor :name attr_accessor :email attr_accessor :website attr_accessor :image attr_accessor :metadata # Creates a new author. # # @param name [String] The name of the author. # @param email [String] The email of the author. # @param website [String] The website of the author. # @param image [String] The URL of the avatar of the author. # @param metadata [HashWithIndifferentAccess] The full list of metadata of this author. # @param uid [String] A unique ID for this post. This is only for client uses. def initialize(name, email = nil, website = nil, image = nil, = nil, uid = nil) @name = name.ensure_string @email = Mbrao::Parser.is_email?(email) ? email : nil @website = Mbrao::Parser.is_url?(website) ? website : nil @image = Mbrao::Parser.is_url?(image) ? image : nil = .ensure_hash(:indifferent) @uid = uid end # Creates an author from a `Hash`. # # @param data [Hash] The data of the author # @return [Author] A new author. def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end end |
Class Method Details
.create(data) ⇒ Author
Creates an author from a Hash.
51 52 53 54 55 56 57 58 59 |
# File 'lib/mbrao/author.rb', line 51 def self.create(data) if data.is_a?(Hash) then data = HashWithIndifferentAccess.new(data) uid = data.delete(:uid) Mbrao::Author.new(data.delete(:name), data.delete(:email), data.delete(:website), data.delete(:image), data, uid) else Mbrao::Author.new(data) end end |