class Slang
Attributes
@return [String] The actual definition.
@return [Integer] The number of thumbs-down the definition has received.
@return [String] An example of the word's usage.
@return [Integer] The UrbanDictionary
definition ID.
@return [String] A permalink to the definition.
@return [Integer] The number of thumbs-up the definition has received.
@return [String] The word being defined.
Public Class Methods
Creates a new Slang
object. @param opts [Hash] The options hash. @option opts [Integer] :id The definition ID. @option opts [String] :word The word being defined. @option opts [String] :author The author of the definition. @option opts [String] :permalink The permalink for the definition. @option opts [String] :definition The definition for the :word @option opts [String] :example An example of its usage. @option opts [Integer] :thumbs_up The number of upvotes the definition has received. @option opts [Integer] :thumbs_down The number of downvotes the definition has received.
# File lib/slang.rb, line 36 def initialize(opts = {}) @id = opts['defid'] || opts[:defid] @word = opts['word'] || opts[:word] @author = opts['author'] || opts[:author] @permalink = opts['permalink'] || opts[:permalink] @definition = opts['definition'] || opts[:definition] @example = opts['example'] || opts[:example] @upvotes = opts['thumbs_up'] || opts[:thumbs_up] @downvotes = opts['thumbs_down'] || opts[:thumbs_down] end
Public Instance Methods
Returns a hash representation of this Slang
object. @return [Hash<Symbol, Integer/String>] See the source for details.
# File lib/slang.rb, line 49 def to_h { id: @id, word: @word, author: @author, permalink: @permalink, definition: @definition, example: @example, upvotes: @upvotes, downvotes: @downvotes } end