Class: MTG
- Inherits:
-
Object
- Object
- MTG
- Defined in:
- lib/mtg_card_finder/mtg.rb
Constant Summary collapse
- ATTRIBUTES =
[ "Card:", "Set:", "Market Value:", "Rise/Fall amount:", "Image URL:" ]
- @@modern_up =
[]
- @@modern_down =
[]
- @@standard_up =
[]
- @@standard_down =
[]
- @@temp_array =
[]
Instance Attribute Summary collapse
-
#card ⇒ Object
Returns the value of attribute card.
-
#image ⇒ Object
Returns the value of attribute image.
-
#market_price ⇒ Object
Returns the value of attribute market_price.
-
#price_fluctuate ⇒ Object
Returns the value of attribute price_fluctuate.
-
#sets ⇒ Object
Returns the value of attribute sets.
Class Method Summary collapse
- .all(format) ⇒ Object
- .create_modern_down(attributes) ⇒ Object
- .create_modern_up(attributes) ⇒ Object
- .create_standard_down(attributes) ⇒ Object
- .create_standard_up(attributes) ⇒ Object
- .modern_down ⇒ Object
- .modern_up ⇒ Object
- .search_modern_down ⇒ Object
- .search_modern_up ⇒ Object
- .search_standard_down ⇒ Object
- .search_standard_up ⇒ Object
- .standard_down ⇒ Object
- .standard_up ⇒ Object
-
.store_temp_array(array) ⇒ Object
hack that resolves glitch that would display duplicate recursions in the selected cards to show by user request in CLI.set_input.
Instance Method Summary collapse
-
#initialize(attributes) ⇒ MTG
constructor
new instance will be created with already assigned values to MTG attrs.
- #save_modern_down ⇒ Object
- #save_modern_up ⇒ Object
- #save_standard_down ⇒ Object
- #save_standard_up ⇒ Object
Constructor Details
#initialize(attributes) ⇒ MTG
new instance will be created with already assigned values to MTG attrs
18 19 20 |
# File 'lib/mtg_card_finder/mtg.rb', line 18 def initialize(attributes) attributes.each {|key, value| self.send("#{key}=", value)} end |
Instance Attribute Details
#card ⇒ Object
Returns the value of attribute card.
2 3 4 |
# File 'lib/mtg_card_finder/mtg.rb', line 2 def card @card end |
#image ⇒ Object
Returns the value of attribute image.
2 3 4 |
# File 'lib/mtg_card_finder/mtg.rb', line 2 def image @image end |
#market_price ⇒ Object
Returns the value of attribute market_price.
2 3 4 |
# File 'lib/mtg_card_finder/mtg.rb', line 2 def market_price @market_price end |
#price_fluctuate ⇒ Object
Returns the value of attribute price_fluctuate.
2 3 4 |
# File 'lib/mtg_card_finder/mtg.rb', line 2 def price_fluctuate @price_fluctuate end |
#sets ⇒ Object
Returns the value of attribute sets.
2 3 4 |
# File 'lib/mtg_card_finder/mtg.rb', line 2 def sets @sets end |
Class Method Details
.all(format) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mtg_card_finder/mtg.rb', line 55 def self.all(format) #iterate through each instance that was appended into class variable during initialization format.each_with_index do |card, number| puts "" puts "|- #{number + 1} -|".fg COLORS[4] puts "" #line below helps resolve glitch that allows 'ghost/invalid' cards to be selected from Parser.purchase if number < Parser.table_length #iterate through each instance method that was defined for the stored instance variable card.instance_variables.each_with_index do |value, index| #returns the value of the instance method applied to the instance #with an index value of the first/last, key/value pairs ordered in Parser.scrape_cards #associates a named definition of the values by titling it from constant ATTRIBUTES if index < 4 puts "#{ATTRIBUTES[index].fg COLORS[2]} #{card.instance_variable_get(value)}" end end end puts "" print " ".bg COLORS[7] end end |
.create_modern_down(attributes) ⇒ Object
43 44 45 |
# File 'lib/mtg_card_finder/mtg.rb', line 43 def self.create_modern_down(attributes) cards = MTG.new(attributes).tap {|card| card.save_modern_down} end |
.create_modern_up(attributes) ⇒ Object
38 39 40 41 |
# File 'lib/mtg_card_finder/mtg.rb', line 38 def self.create_modern_up(attributes) #allows cards instance to auto return thanks to tap implementation cards = MTG.new(attributes).tap {|card| card.save_modern_up} end |
.create_standard_down(attributes) ⇒ Object
51 52 53 |
# File 'lib/mtg_card_finder/mtg.rb', line 51 def self.create_standard_down(attributes) cards = MTG.new(attributes).tap {|card| card.save_standard_down} end |
.create_standard_up(attributes) ⇒ Object
47 48 49 |
# File 'lib/mtg_card_finder/mtg.rb', line 47 def self.create_standard_up(attributes) cards = MTG.new(attributes).tap {|card| card.save_standard_up} end |
.modern_down ⇒ Object
106 107 108 |
# File 'lib/mtg_card_finder/mtg.rb', line 106 def self.modern_down @@modern_down end |
.modern_up ⇒ Object
102 103 104 |
# File 'lib/mtg_card_finder/mtg.rb', line 102 def self.modern_up @@modern_up end |
.search_modern_down ⇒ Object
90 91 92 |
# File 'lib/mtg_card_finder/mtg.rb', line 90 def self.search_modern_down self.all(@@modern_down) end |
.search_modern_up ⇒ Object
86 87 88 |
# File 'lib/mtg_card_finder/mtg.rb', line 86 def self.search_modern_up self.all(@@modern_up) end |
.search_standard_down ⇒ Object
98 99 100 |
# File 'lib/mtg_card_finder/mtg.rb', line 98 def self.search_standard_down self.all(@@standard_down) end |
.search_standard_up ⇒ Object
94 95 96 |
# File 'lib/mtg_card_finder/mtg.rb', line 94 def self.search_standard_up self.all(@@standard_up) end |
.standard_down ⇒ Object
114 115 116 |
# File 'lib/mtg_card_finder/mtg.rb', line 114 def self.standard_down @@standard_down end |
.standard_up ⇒ Object
110 111 112 |
# File 'lib/mtg_card_finder/mtg.rb', line 110 def self.standard_up @@standard_up end |
.store_temp_array(array) ⇒ Object
hack that resolves glitch that would display duplicate recursions in the selected cards to show by user request in CLI.set_input
80 81 82 83 84 |
# File 'lib/mtg_card_finder/mtg.rb', line 80 def self.store_temp_array(array) @@temp_array = array self.all(@@temp_array) @@temp_array.clear end |
Instance Method Details
#save_modern_down ⇒ Object
26 27 28 |
# File 'lib/mtg_card_finder/mtg.rb', line 26 def save_modern_down @@modern_down << self end |
#save_modern_up ⇒ Object
22 23 24 |
# File 'lib/mtg_card_finder/mtg.rb', line 22 def save_modern_up @@modern_up << self end |
#save_standard_down ⇒ Object
34 35 36 |
# File 'lib/mtg_card_finder/mtg.rb', line 34 def save_standard_down @@standard_down << self end |
#save_standard_up ⇒ Object
30 31 32 |
# File 'lib/mtg_card_finder/mtg.rb', line 30 def save_standard_up @@standard_up << self end |