-
Notifications
You must be signed in to change notification settings - Fork 6
/
page_fragments.rb
120 lines (101 loc) · 2.91 KB
/
page_fragments.rb
1
2
3
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
41
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# == description: Individual page fragments that will be used ny another template in order to construct the entire list
require 'erb'
require_relative 'mf_recipe'
def output_tr recipe, mat, i
c = recipe.new(mat, i)
$top5.add(c)
c.as_tr
end
def top5
template = %{
<table>
<caption><a name="Top 5">Top 5 "Quick Sell" Recipes</caption>
<%= CommonRecipe.table_header %>
<% $top5.each do | item |%>
<%= item.as_tr "lvl0"%>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def generic caption, recipeType
template = %{
<table>
<caption><a name="<%= caption %>"><%= caption %></a></caption>
<%= recipeType.table_header %>
<% recipeType.each do | item |%>
<%= recipeType.new(item).as_tr %>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def lodestones
#generic("Lodestones", LodestoneRecipe)
template = %{
<table id="lodestones">
<caption>Lodestones</caption>
<%= LodestoneRecipe.table_header %>
<% LodestoneRecipe.each do | lodestone |%>
<% 5.downto(2).each do | i | %>
<%= LodestoneRecipe.new(lodestone, i).as_tr %>
<% end %>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def dust
template = %{
<table id="common">
<caption>Dust</caption>
<%= CommonRecipe.table_header %>
<% ["Dust" ].each do | mat |%>
<% 6.downto(2).each do | i | %>
<%= DustRecipe.new(mat, i).as_tr %>
<% end %>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def common_crafting_materials
template = %{
<table id="common">
<caption>Common Crafting Materials</caption>
<%= CommonRecipe.table_header %>
<% CommonRecipe.each do | mat |%>
<% 6.downto(2).each do | i | %>
<%= output_tr(CommonRecipe, mat, i) %>
<% end %>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def fine_crafting_materials
template = %{
<table id="fine">
<caption>Fine Crafting Materials</caption>
<%= FineRecipe.table_header %>
<% FineRecipe.each do | mat |%>
<% 6.downto(2).each do | i | %>
<%= output_tr(FineRecipe, mat, i) %>
<% end %>
<% end %>
</table>
}
ERB.new(template).result(binding)
end
def gifts
generic("Gifts", GiftRecipe)
end
def mystic_weapons
generic("Mystic Weapons", MysticWeaponRecipe)
end
def mystic_forge_recipes
generic("Mystic Forge Recipes", MysticForgeRecipe)
end
def pendants
generic("Pendants", PendantRecipe)
end