Class: Middleman::AsciiDoc::AuthorData

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-asciidoc/extension.rb

Constant Summary collapse

UrlWithUsernameRx =
/^(.+?)\[@([^\]]+)\]$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, email_or_url = nil) ⇒ AuthorData

Returns a new instance of AuthorData.



352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/middleman-asciidoc/extension.rb', line 352

def initialize name, email_or_url = nil
  @name = name
  if email_or_url
    if email_or_url.start_with? 'https://', 'http://'
      if (email_or_url.include? '[') && UrlWithUsernameRx =~ email_or_url
        @url, @username = $1, $2
      else
        @url = email_or_url
      end
    else
      @email = email_or_url
    end
  end
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



350
351
352
# File 'lib/middleman-asciidoc/extension.rb', line 350

def email
  @email
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name.



350
351
352
# File 'lib/middleman-asciidoc/extension.rb', line 350

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



350
351
352
# File 'lib/middleman-asciidoc/extension.rb', line 350

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



350
351
352
# File 'lib/middleman-asciidoc/extension.rb', line 350

def username
  @username
end