wowget 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/wowget/item.rb +15 -0
  2. data/spec/item_spec.rb +4 -0
  3. metadata +2 -2
data/lib/wowget/item.rb CHANGED
@@ -2,6 +2,7 @@ require 'net/http'
2
2
  require 'open-uri'
3
3
  require 'nokogiri'
4
4
  require 'json'
5
+ require 'colored'
5
6
 
6
7
  module Wowget
7
8
  class Item
@@ -252,6 +253,20 @@ module Wowget
252
253
  INVENTORY_SLOTS[self.inventory_slot_id]
253
254
  end
254
255
 
256
+ def to_link
257
+ color = case self.quality.downcase.to_sym
258
+ when :poor then 'white'
259
+ when :common then 'white'
260
+ when :uncommon then 'green'
261
+ when :rare then 'blue'
262
+ when :epic then 'magenta'
263
+ when :legendary then 'red'
264
+ when :artifact then 'yellow'
265
+ when :heirloom then 'yellow'
266
+ end
267
+ Colored.colorize "[#{self.name}]", :foreground => color
268
+ end
269
+
255
270
  private
256
271
 
257
272
  def id_from_string(string)
data/spec/item_spec.rb CHANGED
@@ -65,6 +65,10 @@ describe Wowget::Item do
65
65
  item.buy_price.should == 12311
66
66
  end
67
67
 
68
+ it "should produce a colorised link" do
69
+ item.to_link.should == "\e[32m[Blessed Claymore]\e[0m"
70
+ end
71
+
68
72
  end
69
73
 
70
74
  describe "With an ID passed as a string" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wowget
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.5
5
+ version: 0.1.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Darlow
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-29 00:00:00 +01:00
13
+ date: 2011-07-04 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency