Module: PrettyMagic::ManaIcons::ClassMethods
- Included in:
- PrettyMagic::ManaIcons
- Defined in:
- lib/pretty_magic/mana_icons.rb
Instance Method Summary collapse
- #add_icons_to_text(long_text, options = {}) ⇒ Object
- #card_symbols(symbolText, options = {}) ⇒ Object
- #guild_symbols(symbolText, options = {}) ⇒ Object
- #mana_symbols(symbolText, options = {}) ⇒ Object
- #poleis_symbols(symbolText, options = {}) ⇒ Object
Instance Method Details
#add_icons_to_text(long_text, options = {}) ⇒ Object
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/pretty_magic/mana_icons.rb', line 118 def add_icons_to_text(long_text, = {}) = {cost: true, shadow: false, size: 1, fixed_width: false}.merge() pretty_text = long_text.gsub(/{.+?}/) { |symbolText| use_all_symbols(symbolText, { cost: [:cost], shadow: [:shadow], size: [:size], fixed_width: [:fixed_width]} ) } pretty_text end |
#card_symbols(symbolText, options = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/pretty_magic/mana_icons.rb', line 42 def card_symbols(symbolText, = {}) = {cost: false, shadow: false, size: 1, fixed_width: false, loyalty: nil, saga_number: nil}.merge() prettySymbol = "" loyalty = [:loyalty] saga_number = [:saga_number] case symbolText.upcase when '{T}' prettySymbol = "ms-tap" when '{Q}' prettySymbol = "ms-untap" when '{PW}' prettySymbol = "ms-planeswalker" else prettySymbol = "" end easy_match = symbolText.upcase[/{(TAP|UNTAP|TAP-ALT|CHAOS|ARTIFACT|CREATURE|ENCHANTMENT|INSTANT|LAND|PLANESWALKER|SORCERY|MULTIPLE|FLASHBACK|LOYALTY-UP|LOYALTY-DOWN|LOYALTY-ZERO|LOYALTY-START|DFC-DAY|DFC-NIGHT|DFC-SPARK|DFC-IGNITE|DFC-MOON|DFC-EMRAKUL|DFC-ENCHANTMENT|POWER|TOUGHNESS|ARTIST-BRUSH|ARTIST-NIB|SAGA|ACORN)}/, 1] unless easy_match.nil? prettySymbol = "ms-#{easy_match.downcase}" end if prettySymbol == "" symbolText else prettySymbol = ((0...20) === loyalty) ? prettySymbol + " ms-loyalty-#{loyalty}" : prettySymbol prettySymbol = ((0...5) === saga_number) ? prettySymbol + " ms-saga-#{saga_number}" : prettySymbol i_tag(prettySymbol + ' ' + optional_classes([:cost], [:shadow], [:size], [:fixed_width])) end end |
#guild_symbols(symbolText, options = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/pretty_magic/mana_icons.rb', line 76 def guild_symbols(symbolText, = {}) = {cost: false, shadow: false, size: 1, fixed_width: false}.merge() prettySymbol = "" guild_match = symbolText.upcase[/{(AZORIUS|BOROS|DIMIR|GOLGARI|GRUUL|IZZET|ORZHOV|RAKDOS|SELESNYA|SIMIC)}/, 1] unless guild_match.nil? prettySymbol = "ms-guild-#{guild_match.downcase}" end clan_match = symbolText.upcase[/{(ABZAN|JESKAI|MARDU|SULTAI|TEMUR|ATARKA|DROMOKA|KOLAGHAN|OJUTAI|SILUMGAR)}/, 1] unless clan_match.nil? prettySymbol = "ms-clan-#{clan_match.downcase}" end if prettySymbol == "" symbolText else i_tag(prettySymbol + ' ' + optional_classes([:cost], [:shadow], [:size], [:fixed_width])) end end |
#mana_symbols(symbolText, options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/pretty_magic/mana_icons.rb', line 4 def mana_symbols(symbolText, = {}) = {cost: true, shadow: false, size: 1, fixed_width: false}.merge() prettySymbol = "" easy_match = "" split_match = "" # first handle special cases that are not that easy to convert case symbolText.upcase when '{½}', '{1/2}' prettySymbol = "ms-1-2" when '{∞}' prettySymbol = "ms-infinity" else prettySymbol = "" end # easy matches, just one letter or number easy_match = symbolText.upcase[/{(X|Y|Z|0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|100|1000000|INFINITY|P|HW|HR|W|U|B|R|G|C|S|E)}/, 1] # split or hybrids split_match = symbolText.upcase[/{(W\/U|W\/B|B\/R|B\/G|U\/B|U\/R|R\/G|R\/W|G\/W|G\/U|2\/W|2\/U|2\/B|2\/R|2\/G|W\/P|U\/P|B\/P|R\/P|G\/P)}/, 1] unless easy_match.nil? prettySymbol = "ms-#{easy_match.downcase}" end unless split_match.nil? prettySymbol = "ms-#{split_match.downcase.gsub("/", "")}" end if prettySymbol == "" symbolText else i_tag(prettySymbol + ' ' + optional_classes([:cost], [:shadow], [:size], [:fixed_width])) end end |
#poleis_symbols(symbolText, options = {}) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/pretty_magic/mana_icons.rb', line 99 def poleis_symbols(symbolText, = {}) = {cost: false, shadow: false, size: 1, fixed_width: false}.merge() prettySymbol = "" poleis_match = symbolText.upcase[/{(SETESSA|AKROS|MELETIS)}/, 1] unless poleis_match.nil? # according to mana font docs, polis not poleis for css code prettySymbol = "ms-polis-#{poleis_match.downcase}" end if prettySymbol == "" symbolText else i_tag(prettySymbol + ' ' + optional_classes([:cost], [:shadow], [:size], [:fixed_width])) end end |