Class: BadASS::Toy

Inherits:
Object
  • Object
show all
Defined in:
lib/badass/toy.rb

Overview

Base class containing a Bad Dragon toy and it’s attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(toy_hash) ⇒ Toy

Create a Toy object using a hash from the API.

Parameters:

  • (Hash)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/badass/toy.rb', line 5

def initialize(toy_hash)
  @id = toy_hash['id']
  @sku = toy_hash['sku']
  @size = toy_hash['size']
  @firmness = toy_hash['firmness']
  @price = toy_hash['price']
  @weight = toy_hash['weight']
  @color = toy_hash['color']
  @colors = [toy_hash['color1'], toy_hash['color2'], toy_hash['color3']]
  @flop_reason = toy_hash['flop_reason'].capitalize
  @type = toy_hash['type'].capitalize
  @cumtube = toy_hash['cumtube']
  @suction_cup = toy_hash['suction_cup']
  @images = toy_hash['images'].map { |toy| toy['fullFilename'] }
end

Instance Attribute Details

#colorString (readonly)

Returns the color of the toy.

Returns:

  • (String)

    the color of the toy



56
57
58
# File 'lib/badass/toy.rb', line 56

def color
  @color
end

#colorsArray(Integer, Integer, Integer) (readonly)

Returns the 3 colors of the toy.

Returns:

  • (Array(Integer, Integer, Integer))

    the 3 colors of the toy



58
59
60
# File 'lib/badass/toy.rb', line 58

def colors
  @colors
end

#flop_reasonString (readonly)

Returns the flop reason of a toy.

Returns:

  • (String)

    the flop reason of a toy



60
61
62
# File 'lib/badass/toy.rb', line 60

def flop_reason
  @flop_reason
end

#idInteger (readonly)

Returns the ID of the toy.

Returns:

  • (Integer)

    the ID of the toy



46
47
48
# File 'lib/badass/toy.rb', line 46

def id
  @id
end

#imagesArray (readonly)

Returns the image URLs of a toy.

Returns:

  • (Array)

    the image URLs of a toy



64
65
66
# File 'lib/badass/toy.rb', line 64

def images
  @images
end

#priceInteger (readonly)

Returns the price of the toy.

Returns:

  • (Integer)

    the price of the toy



52
53
54
# File 'lib/badass/toy.rb', line 52

def price
  @price
end

#sizeString (readonly)

Returns the size of the toy.

Returns:

  • (String)

    the size of the toy



50
51
52
# File 'lib/badass/toy.rb', line 50

def size
  @size
end

#skuString (readonly)

Returns the SKU of the toy.

Returns:

  • (String)

    the SKU of the toy



48
49
50
# File 'lib/badass/toy.rb', line 48

def sku
  @sku
end

#typeString (readonly)

Returns the type of a toy.

Returns:

  • (String)

    the type of a toy



62
63
64
# File 'lib/badass/toy.rb', line 62

def type
  @type
end

#weightFloat (readonly)

Returns the weight of the toy.

Returns:

  • (Float)

    the weight of the toy



54
55
56
# File 'lib/badass/toy.rb', line 54

def weight
  @weight
end

Instance Method Details

#cumtube?Boolean

Checks if a toy has a cumtube or not.

Returns:

  • (Boolean)


29
30
31
# File 'lib/badass/toy.rb', line 29

def cumtube?
  @cumtube == 1
end

#firmnessString

Gets the firmness of a toy.

Returns:

  • (String)


41
42
43
# File 'lib/badass/toy.rb', line 41

def firmness
  BadASS::FIRMNESSES[@firmness]
end

#nameString

Gets the full product name of the toy.

Returns:

  • (String)


23
24
25
# File 'lib/badass/toy.rb', line 23

def name
  BadASS::BAD_DRAGON_SKUS[@sku]
end

#suction_cup?Boolean

Checks if a toy has a suction cup or not.

Returns:

  • (Boolean)


35
36
37
# File 'lib/badass/toy.rb', line 35

def suction_cup?
  @suction_cup == 1
end