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.


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

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


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

def email
  @email
end

#nameObject (readonly) Also known as: to_s

Returns the value of attribute name


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

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url


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

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username


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

def username
  @username
end