Class: BadASS::Toy
- Inherits:
-
Object
- Object
- BadASS::Toy
- Defined in:
- lib/badass/toy.rb
Overview
Base class containing a Bad Dragon toy and it’s attributes.
Instance Attribute Summary collapse
-
#color ⇒ String
readonly
The color of the toy.
-
#colors ⇒ Array(Integer, Integer, Integer)
readonly
The 3 colors of the toy.
-
#flop_reason ⇒ String
readonly
The flop reason of a toy.
-
#id ⇒ Integer
readonly
The ID of the toy.
-
#images ⇒ Array
readonly
The image URLs of a toy.
-
#price ⇒ Integer
readonly
The price of the toy.
-
#size ⇒ String
readonly
The size of the toy.
-
#sku ⇒ String
readonly
The SKU of the toy.
-
#type ⇒ String
readonly
The type of a toy.
-
#weight ⇒ Float
readonly
The weight of the toy.
Instance Method Summary collapse
-
#cumtube? ⇒ Boolean
Checks if a toy has a cumtube or not.
-
#firmness ⇒ String
Gets the firmness of a toy.
-
#initialize(toy_hash) ⇒ Toy
constructor
Create a Toy object using a hash from the API.
-
#name ⇒ String
Gets the full product name of the toy.
-
#suction_cup? ⇒ Boolean
Checks if a toy has a suction cup or not.
Constructor Details
#initialize(toy_hash) ⇒ Toy
Create a Toy object using a hash from the API.
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
#color ⇒ String (readonly)
Returns the color of the toy.
56 57 58 |
# File 'lib/badass/toy.rb', line 56 def color @color end |
#colors ⇒ Array(Integer, Integer, Integer) (readonly)
Returns the 3 colors of the toy.
58 59 60 |
# File 'lib/badass/toy.rb', line 58 def colors @colors end |
#flop_reason ⇒ String (readonly)
Returns the flop reason of a toy.
60 61 62 |
# File 'lib/badass/toy.rb', line 60 def flop_reason @flop_reason end |
#id ⇒ Integer (readonly)
Returns the ID of the toy.
46 47 48 |
# File 'lib/badass/toy.rb', line 46 def id @id end |
#images ⇒ Array (readonly)
Returns the image URLs of a toy.
64 65 66 |
# File 'lib/badass/toy.rb', line 64 def images @images end |
#price ⇒ Integer (readonly)
Returns the price of the toy.
52 53 54 |
# File 'lib/badass/toy.rb', line 52 def price @price end |
#size ⇒ String (readonly)
Returns the size of the toy.
50 51 52 |
# File 'lib/badass/toy.rb', line 50 def size @size end |
#sku ⇒ String (readonly)
Returns the SKU of the toy.
48 49 50 |
# File 'lib/badass/toy.rb', line 48 def sku @sku end |
#type ⇒ String (readonly)
Returns the type of a toy.
62 63 64 |
# File 'lib/badass/toy.rb', line 62 def type @type end |
#weight ⇒ Float (readonly)
Returns 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.
29 30 31 |
# File 'lib/badass/toy.rb', line 29 def cumtube? @cumtube == 1 end |
#firmness ⇒ String
Gets the firmness of a toy.
41 42 43 |
# File 'lib/badass/toy.rb', line 41 def firmness BadASS::FIRMNESSES[@firmness] end |
#name ⇒ String
Gets the full product name of the toy.
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.
35 36 37 |
# File 'lib/badass/toy.rb', line 35 def suction_cup? @suction_cup == 1 end |