Class: GamesAndRpgParadise::MagicTheGathering::ParseCardFormat
- Inherits:
-
Base
- Object
- Base
- Base
- GamesAndRpgParadise::MagicTheGathering::ParseCardFormat
show all
- Defined in:
- lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb
Overview
Constant Summary
collapse
- DEFAULT_TEST_STRING =
#
DEFAULT_TEST_STRING
This string can be used to test the custom format we will be using for the cards.
#
'
---
Kird Ape
Common
/home/Temp/Magic_the_gathering/Eternal_Masters/Kird_Ape.jpg
Red
137
---'
Constants inherited
from Base
Base::LOG_DIR
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Instance Method Summary
collapse
Methods inherited from Base
[], #convert, #ensure_that_the_log_directory_exists, #esystem, #is_png_file?, #lightgreen, #log_dir?, #opnn, #orange, #palegoldenrod, #pngopt, #rev, #slateblue, #springgreen, #turquoise, #write_what_into
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments
#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(i = DEFAULT_TEST_STRING, run_already = true) ⇒ ParseCardFormat
40
41
42
43
44
45
46
47
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 40
def initialize(
i = DEFAULT_TEST_STRING,
run_already = true
)
reset
parse_this_string(i)
run if run_already
end
|
Instance Method Details
#assign_proper_entries ⇒ Object
#
assign_proper_entries
This method will assign the proper entries.
#
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 112
def assign_proper_entries
_ = dataset?
@name_of_the_card = _[0] @rarity_of_the_card = _[1] @local_path_to_the_card = _[2] @card_colour = _[3] @card_number = _[4] @remote_url_to_the_card = _[5] if @local_path_to_the_card and @name_of_the_card_set.empty?
@name_of_the_card_set = determine_card_set_from(@local_path_to_the_card)
end
end
|
#card_number? ⇒ Boolean
138
139
140
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 138
def card_number?
@card_number
end
|
#converted_mana_cost_of_the_card? ⇒ Boolean
#
converted_mana_cost_of_the_card?
#
145
146
147
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 145
def converted_mana_cost_of_the_card?
0 end
|
#dataset? ⇒ Boolean
103
104
105
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 103
def dataset?
@dataset
end
|
#determine_card_set_from(i) ⇒ Object
#
determine_card_set_from
#
168
169
170
171
172
173
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 168
def determine_card_set_from(i)
if i.end_with?('.jpg') and i.count('/') > 2
i = i.split('/')[4] end
return i
end
|
#local_path? ⇒ Boolean
Also known as:
url?
161
162
163
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 161
def local_path?
@local_path
end
|
#name_of_the_card? ⇒ Boolean
Also known as:
name?, card_name?
178
179
180
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 178
def name_of_the_card?
@name_of_the_card
end
|
#name_of_the_set? ⇒ Boolean
131
132
133
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 131
def name_of_the_set?
@name_of_the_card_set
end
|
#parse_this_string(i) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 75
def parse_this_string(i)
i = DEFAULT_TEST_STRING if i.nil?
if i.is_a? Array
if i.empty?
i << DEFAULT_TEST_STRING
end
i = i.join
end
if i.is_a? String and i.frozen?
i = i.dup
end
i.lstrip! i.delete!('-') if i.include? '---'
i = i.split(N) i.reject! {|entry| entry.strip.empty? }
set_dataset(i) end
|
#purge_dataset_variable ⇒ Object
#
purge_dataset_variable
Get rid of the @dataset variable again.
#
154
155
156
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 154
def purge_dataset_variable
remove_instance_variable(:@dataset)
end
|
#rarity_of_the_card? ⇒ Boolean
Also known as:
return_rarity, rarity_of_the_card
186
187
188
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 186
def rarity_of_the_card?
@rarity_of_the_card
end
|
#remote_url_to_the_card? ⇒ Boolean
Also known as:
remote_url_to_the_card
#
remote_url_to_the_card?
#
194
195
196
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 194
def remote_url_to_the_card?
@remote_url_to_the_card.to_s
end
|
#reset ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 52
def reset
super()
@name_of_the_card_set = '' @name_of_the_card = nil
@rarity_of_the_card = nil
@local_path_to_the_card = nil
@card_number = nil
@card_colour = nil
@remote_url_to_the_card = nil
end
|
#run ⇒ Object
201
202
203
204
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 201
def run
assign_proper_entries
purge_dataset_variable
end
|
#set_dataset(i) ⇒ Object
96
97
98
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/parse_card_format.rb', line 96
def set_dataset(i)
@dataset = i
end
|