Class: Wowr::Classes::Item
- Inherits:
-
Object
- Object
- Wowr::Classes::Item
- Defined in:
- lib/wowr/item.rb
Overview
Most basic Composed of an ItemInfo and Needs to be consolidated with ItemInfo and other stuff to be a parent class that they extend? TODO: At the moment needs a reference to the API in order to get the base URL for icons TODO: Make extend Icon class
Direct Known Subclasses
CreatedItem, DisenchantItem, EquippedItem, FullItem, GuildBankBag, GuildBankItem, GuildBankLogItem, ItemCostToken, ItemCreation, ItemInfo, ItemTooltip, PlanItem, Reagent, SearchItem
Constant Summary collapse
- @@icon_url_base =
'images/icons/'
- @@icon_sizes =
{:large => ['64x64', 'jpg'], :medium => ['43x43', 'png'], :small => ['21x21', 'png']}
Instance Attribute Summary collapse
-
#icon_base ⇒ Object
readonly
Returns the value of attribute icon_base.
-
#id ⇒ Object
(also: #item_id, #to_i)
readonly
Returns the value of attribute id.
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #icon(size = :medium) ⇒ Object
-
#initialize(elem, api = nil) ⇒ Item
constructor
A new instance of Item.
Constructor Details
#initialize(elem, api = nil) ⇒ Item
Returns a new instance of Item.
29 30 31 32 33 34 35 |
# File 'lib/wowr/item.rb', line 29 def initialize(elem, api = nil) @api = api @id = elem[:id].to_i @name = elem[:name] @icon_base = elem[:icon] end |
Instance Attribute Details
#icon_base ⇒ Object (readonly)
Returns the value of attribute icon_base.
21 22 23 |
# File 'lib/wowr/item.rb', line 21 def icon_base @icon_base end |
#id ⇒ Object (readonly) Also known as: item_id, to_i
Returns the value of attribute id.
21 22 23 |
# File 'lib/wowr/item.rb', line 21 def id @id end |
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
21 22 23 |
# File 'lib/wowr/item.rb', line 21 def name @name end |
Instance Method Details
#icon(size = :medium) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/wowr/item.rb', line 37 def icon(size = :medium) if !@@icon_sizes.include?(size) raise Wowr::Exceptions::InvalidIconSize.new(@@icon_sizes) end if @api base = @api.base_url else base = 'http://www.wowarmory.com/' end # http://www.wowarmory.com/images/icons/64x64/blahblah.jpg return base + @@icon_url_base + @@icon_sizes[size][0] + '/' + @icon_base + '.' + @@icon_sizes[size][1] end |