Class: CrateAPI::CrateObject Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/crate_api/crateobject.rb

Overview

This class is abstract.

Subclass in order to get the basic :short_code , :name , :id params that every object should have.

Base class for Crate and Item objects

Direct Known Subclasses

Crate, Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ CrateObject

The default initializer for the CrateObject class

Parameters:

  • a (Hash)

    hash of values used to initialize the CrateObject.

  • opts (Hash)

    a customizable set of options



17
18
19
20
21
# File 'lib/crate_api/crateobject.rb', line 17

def initialize(hash)
  @short_code = hash["short_code"]
  @name = hash["name"]
  @id = hash["id"]
end

Instance Attribute Details

#idObject (readonly)



8
9
10
# File 'lib/crate_api/crateobject.rb', line 8

def id
  @id
end

#nameObject (readonly)



8
9
10
# File 'lib/crate_api/crateobject.rb', line 8

def name
  @name
end

#short_codeObject (readonly)



8
9
10
# File 'lib/crate_api/crateobject.rb', line 8

def short_code
  @short_code
end

Instance Method Details

#short_urlString

Will return the shortened url of a given object

Returns:

  • (String)

    shortened url string for a given object.



26
27
28
# File 'lib/crate_api/crateobject.rb', line 26

def short_url
  return "#{CrateAPI::Base::SHORT_URL}" % ["#{@short_code}"]
end