Class: ModsDisplay::Name::Person

Inherits:
Object
  • Object
show all
Defined in:
lib/mods_display/fields/name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Person

Returns a new instance of Person.



76
77
78
79
# File 'lib/mods_display/fields/name.rb', line 76

def initialize(data)
  @name = data[:name]
  @role = data[:role] ? data[:role].text : nil
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



75
76
77
# File 'lib/mods_display/fields/name.rb', line 75

def name
  @name
end

#roleObject

Returns the value of attribute role.



75
76
77
# File 'lib/mods_display/fields/name.rb', line 75

def role
  @role
end

Instance Method Details

#to_sObject



81
82
83
84
85
# File 'lib/mods_display/fields/name.rb', line 81

def to_s
  text = @name.dup
  text << " (#{@role})" if @role
  text
end