class Epuber::Book::Contributor
Attributes
file_as[R]
File-as of contributor used in .opf file @return [String] pretty name
pretty_name[R]
Pretty name of contributor used in .opf file and copyright page @return [String] pretty name
role[R]
Role of contributor @return [String] role
Public Class Methods
from_obj(obj, role = 'aut')
click to toggle source
Creates new instance of Contributor
dependent on obj content
@param [Hash<Symbol, String>, Array<Hash<Symbol,String>, String, Array<String>] obj input object @param [String] role role of contributor
@return [Contributor]
# File lib/epuber/book/contributor.rb, line 39 def self.from_obj(obj, role = 'aut') if obj.is_a?(String) components = obj.split if components.length >= 2 NormalContributor.new(components.first(components.length - 1).join(' '), components.last, role) else Contributor.new(obj, obj, role) end elsif obj.is_a?(Hash) if obj.key?(:first_name) NormalContributor.new(obj[:first_name], obj[:last_name], obj[:role] || role) elsif obj.key?(:file_as) Contributor.new(obj[:pretty_name], obj[:file_as], obj[:role] || role) elsif obj.key?(:name) Contributor.from_obj(obj[:name], obj[:role] || role) end end end
new(pretty_name, file_as, role)
click to toggle source
@param [String] pretty_name
pretty name of contributor @param [String] file_as
file as of contributor @param [String] role contributor role
# File lib/epuber/book/contributor.rb, line 26 def initialize(pretty_name, file_as, role) @file_as = file_as @pretty_name = pretty_name @role = role end