Class: Ronin::Core::Metadata::Authors::Author

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/core/metadata/authors/author.rb

Overview

Represents author metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, email: nil, pgp: nil, website: nil, blog: nil, github: nil, gitlab: nil, twitter: nil, mastodon: nil, discord: nil) ⇒ Author

Initializes the author.

Parameters:

  • name (String)

    The author's name.

  • email (String, nil) (defaults to: nil)

    The author's email.

  • pgp (String, nil) (defaults to: nil)

    The author's PGP Key ID.

  • website (String, nil) (defaults to: nil)

    The author's website.

  • blog (String, nil) (defaults to: nil)

    The author's blog.

  • github (String, nil) (defaults to: nil)

    The author's GitHub user name.

  • gitlab (String, nil) (defaults to: nil)

    The author's GitLab user name.

  • twitter (String, nil) (defaults to: nil)

    The author's Twitter handle.

  • mastodon (String, nil) (defaults to: nil)

    The author's Mastodon handle.

  • discord (String, nil) (defaults to: nil)

    The author's Discord handle.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ronin/core/metadata/authors/author.rb', line 113

def initialize(name, email:    nil,
                     pgp:      nil,
                     website:  nil,
                     blog:     nil,
                     github:   nil,
                     gitlab:   nil,
                     twitter:  nil,
                     mastodon: nil,
                     discord:  nil)
  @name  = name
  @email = email
  @pgp   = pgp

  @website  = website
  @blog     = blog
  @github   = github
  @gitlab   = gitlab
  @twitter  = twitter
  @mastodon = mastodon
  @discord  = discord
end

Instance Attribute Details

#blogString? (readonly)

The author's blog.

Returns:

  • (String, nil)


51
52
53
# File 'lib/ronin/core/metadata/authors/author.rb', line 51

def blog
  @blog
end

#discordString? (readonly)

The author's Discord handle.

Returns:

  • (String, nil)


78
79
80
# File 'lib/ronin/core/metadata/authors/author.rb', line 78

def discord
  @discord
end

#emailString? (readonly)

The author's email.

Returns:

  • (String, nil)


36
37
38
# File 'lib/ronin/core/metadata/authors/author.rb', line 36

def email
  @email
end

#githubString? (readonly)

The author's GitHub user name.

Returns:

  • (String, nil)


56
57
58
# File 'lib/ronin/core/metadata/authors/author.rb', line 56

def github
  @github
end

#gitlabString? (readonly)

The author's GitLab user name.

Returns:

  • (String, nil)


61
62
63
# File 'lib/ronin/core/metadata/authors/author.rb', line 61

def gitlab
  @gitlab
end

#mastodonString? (readonly)

The author's Mastodon handle.

Returns:

  • (String, nil)

Since:

  • 0.2.0



73
74
75
# File 'lib/ronin/core/metadata/authors/author.rb', line 73

def mastodon
  @mastodon
end

#nameString (readonly)

The author's name.

Returns:

  • (String)


31
32
33
# File 'lib/ronin/core/metadata/authors/author.rb', line 31

def name
  @name
end

#pgpString? (readonly)

The author's PGP Key ID.

Returns:

  • (String, nil)


41
42
43
# File 'lib/ronin/core/metadata/authors/author.rb', line 41

def pgp
  @pgp
end

#twitterString? (readonly)

The author's Twitter handle.

Returns:

  • (String, nil)


66
67
68
# File 'lib/ronin/core/metadata/authors/author.rb', line 66

def twitter
  @twitter
end

#websiteString? (readonly)

The author's website

Returns:

  • (String, nil)


46
47
48
# File 'lib/ronin/core/metadata/authors/author.rb', line 46

def website
  @website
end

Instance Method Details

#blog?Boolean

Determines if the author has a #blog set.

Returns:

  • (Boolean)


167
168
169
# File 'lib/ronin/core/metadata/authors/author.rb', line 167

def blog?
  @blog != nil
end

#discord?Boolean

Determines if the author has a #discord handle set.

Returns:

  • (Boolean)


214
215
216
# File 'lib/ronin/core/metadata/authors/author.rb', line 214

def discord?
  @discord != nil
end

#email?Boolean

Determines if the author has an #email set.

Returns:

  • (Boolean)


140
141
142
# File 'lib/ronin/core/metadata/authors/author.rb', line 140

def email?
  @email != nil
end

#github?Boolean

Determines if the author has a #github user name set.

Returns:

  • (Boolean)


176
177
178
# File 'lib/ronin/core/metadata/authors/author.rb', line 176

def github?
  @github != nil
end

#github_urlString?

Returns the URL to the author's GitHub profile.

Returns:

  • (String, nil)

    Returns the URL to the author's GitHub profile, or nil if no #github user name has been set.



225
226
227
# File 'lib/ronin/core/metadata/authors/author.rb', line 225

def github_url
  "https://github.com/#{@github.sub(/\A@/,'')}" if @github
end

#gitlab?Boolean

Determines if the author has a #gitlab user name set.

Returns:

  • (Boolean)


185
186
187
# File 'lib/ronin/core/metadata/authors/author.rb', line 185

def gitlab?
  @gitlab != nil
end

#gitlab_urlString?

Returns the URL to the author's GitLab profile.

Returns:

  • (String, nil)

    Returns the URL to the author's GitLab profile, or nil if no #gitlab user name has been set.



236
237
238
# File 'lib/ronin/core/metadata/authors/author.rb', line 236

def gitlab_url
  "https://gitlab.com/#{@gitlab.sub(/\A@/,'')}" if @gitlab
end

#mastodon?Boolean

Determines if the author has a #mastodon handle set.

Returns:

  • (Boolean)

Since:

  • 0.2.0



205
206
207
# File 'lib/ronin/core/metadata/authors/author.rb', line 205

def mastodon?
  @mastodon != nil
end

#mastodon_urlString?

Returns the URL to the author's Mastodon profile.

Returns:

  • (String, nil)

    Returns the URL to the author's Mastodon profile, or nil if no #mastodon user name has been set.

Since:

  • 0.2.0



260
261
262
263
264
265
266
# File 'lib/ronin/core/metadata/authors/author.rb', line 260

def mastodon_url
  if @mastodon
    username, host = @mastodon.sub(/\A@/,'').split('@',2)

    "https://#{host}/@#{username}"
  end
end

#pgp?Boolean

Determines if the author has a #pgp Key ID set.

Returns:

  • (Boolean)


149
150
151
# File 'lib/ronin/core/metadata/authors/author.rb', line 149

def pgp?
  @pgp != nil
end

#to_sString

Converts the author to a String.

Returns:

  • (String)

    The author's name and/or email.



274
275
276
277
278
# File 'lib/ronin/core/metadata/authors/author.rb', line 274

def to_s
  if @email then "#{@name} <#{@email}>"
  else           @name
  end
end

#twitter?Boolean

Determines if the author has a #twitter handle set.

Returns:

  • (Boolean)


194
195
196
# File 'lib/ronin/core/metadata/authors/author.rb', line 194

def twitter?
  @twitter != nil
end

#twitter_urlString?

Returns the URL to the author's Twitter profile.

Returns:

  • (String, nil)

    Returns the URL to the author's Twitter profile, or nil if no #twitter user name has been set.



247
248
249
# File 'lib/ronin/core/metadata/authors/author.rb', line 247

def twitter_url
  "https://twitter.com/#{@twitter.sub(/\A@/,'')}" if @twitter
end

#website?Boolean

Determines if the author has a #website set.

Returns:

  • (Boolean)


158
159
160
# File 'lib/ronin/core/metadata/authors/author.rb', line 158

def website?
  @website != nil
end