Class: Ruqqus::Badge

Inherits:
Object
  • Object
show all
Defined in:
lib/ruqqus/types/badge.rb

Overview

Describes a trophy that can be earned/issued to an account for specific accomplishments.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Badge

Creates a new instance of the Ruqqus::Badge class.

Parameters:

  • data (Hash)

    the parsed JSON payload defining this instance.



30
31
32
# File 'lib/ruqqus/types/badge.rb', line 30

def initialize(data)
  @data = data || raise(ArgumentError, 'data cannot be nil')
end

Instance Attribute Details

#createdTime? (readonly)

Returns the time the badge was earned, or nil if not defined.

Returns:

  • (Time?)

    the time the badge was earned, or nil if not defined.



# File 'lib/ruqqus/types/badge.rb', line 22

#created_utcInteger? (readonly)

Returns the time the badge was earned in seconds since the Unix epoch, or 0 if not defined.

Returns:

  • (Integer?)

    the time the badge was earned in seconds since the Unix epoch, or 0 if not defined.



# File 'lib/ruqqus/types/badge.rb', line 18

#nameString? (readonly)

Returns the name of the badge.

Returns:

  • (String?)

    the name of the badge.



# File 'lib/ruqqus/types/badge.rb', line 6

#textString? (readonly)

Returns a brief description of the badge.

Returns:

  • (String?)

    a brief description of the badge.



# File 'lib/ruqqus/types/badge.rb', line 10

#urlString? (readonly)

Returns the URL associated with the badge, or nil if not defined.

Returns:

  • (String?)

    the URL associated with the badge, or nil if not defined.



# File 'lib/ruqqus/types/badge.rb', line 14

Instance Method Details

#to_sString

Returns the string representation of the object.

Returns:

  • (String)

    the string representation of the object.



57
58
59
# File 'lib/ruqqus/types/badge.rb', line 57

def to_s
  @data[:text] || inspect
end