Class: Integrity::Author::AuthorStruct

Inherits:
Struct
  • Object
show all
Defined in:
lib/integrity/author.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



7
8
9
# File 'lib/integrity/author.rb', line 7

def email
  @email
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



7
8
9
# File 'lib/integrity/author.rb', line 7

def name
  @name
end

Class Method Details

.parse(string) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/integrity/author.rb', line 8

def self.parse(string)
  raise ArgumentError.new("invalid author string") unless string =~ /^(.*) <(.*)>$/

  new($1.strip, $2.strip)
end

Instance Method Details

#to_sObject Also known as: full



14
15
16
# File 'lib/integrity/author.rb', line 14

def to_s
  @full ||= "#{name} <#{email}>"
end