Class: GamesAndRpgParadise::MagicTheGathering::SortCards
- Inherits:
-
Base
- Object
- Base
- Base
- GamesAndRpgParadise::MagicTheGathering::SortCards
show all
- Defined in:
- lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb
Overview
GamesAndRpgParadise::MagicTheGathering::SortCards
Constant Summary
collapse
- NAMESPACE =
inspect
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?, #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, #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(this_md_file = ARGV, run_already = true) ⇒ SortCards
#
initialize
The first argument should be the .md file that you wish to sort.
#
33
34
35
36
37
38
39
40
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 33
def initialize(
this_md_file = ARGV,
run_already = true
)
reset
set_md_file(this_md_file)
run if run_already
end
|
Instance Method Details
#hash? ⇒ Boolean
89
90
91
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 89
def hash?
@hash_sorted
end
|
#md_file? ⇒ Boolean
Also known as:
input?
52
53
54
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 52
def md_file?
@md_file
end
|
#opnn ⇒ Object
82
83
84
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 82
def opnn
super(NAMESPACE)
end
|
#reset ⇒ Object
45
46
47
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 45
def reset
super()
end
|
#run ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 96
def run
parsed_cards = ParseMultipleCards.new(input?)
hash = parsed_cards.to_hash
sorted = hash.sort_by {|key, array| key }
_ = {}
sorted.each {|entry|
name = entry.first
array = entry.last
_[name] = array
}
@hash_sorted = _
save_the_file
end
|
#save_the_file ⇒ Object
59
60
61
62
63
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 59
def save_the_file
card_format = File.basename(md_file?.sub(/\.md$/,'').tr('_',' '))
opnn; e "We have #{sfancy(@hash_sorted.keys.size.to_s)} entries."
StoreCardInformation.new(hash?, card_format)
end
|
#set_md_file(i) ⇒ Object
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/games_and_rpg_paradise/games/magic_the_gathering/classes/sort_cards.rb', line 68
def set_md_file(i)
if i.is_a? Array
if i.empty? and !Dir['*.md'].empty?
i << Dir['*.md']
end
i = i.flatten.join(' ').strip
end
i = i.to_s.dup unless i.is_a? String
@md_file = i
end
|