Class: D3MPQ::ModCodeAnalyzer
- Inherits:
-
Object
- Object
- D3MPQ::ModCodeAnalyzer
- Defined in:
- lib/d3_mpq/mod_code_analyzer.rb
Constant Summary collapse
- SEPERATOR =
","
Instance Method Summary collapse
- #attributes ⇒ Object
-
#initialize(parser, files, output = nil) ⇒ ModCodeAnalyzer
constructor
A new instance of ModCodeAnalyzer.
-
#mod_codes ⇒ Object
HACK: hacky implementation right here right now.
- #write ⇒ Object
Constructor Details
#initialize(parser, files, output = nil) ⇒ ModCodeAnalyzer
Returns a new instance of ModCodeAnalyzer.
5 6 7 8 9 |
# File 'lib/d3_mpq/mod_code_analyzer.rb', line 5 def initialize(parser, files, output = nil) @parser = parser.new @files = [*files] @output = output || "mod_code" end |
Instance Method Details
#attributes ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/d3_mpq/mod_code_analyzer.rb', line 22 def attributes return @attributes if @attributes h = Hash.new { |h,k| h[k] = [] } mod_codes.each do |e| mod_code = e[:mod_code] h[mod_code.mod_code] << e[:name] if mod_code.mod_code != 0xFFFFFFFF end @attributes = [] h.each do |mod_code, names| @attributes << { :mod_code => mod_code, :names => names } end @attributes.sort! { |x, y| y[:names].length <=> x[:names].length } return @attributes end |
#mod_codes ⇒ Object
HACK: hacky implementation right here right now
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/d3_mpq/mod_code_analyzer.rb', line 41 def mod_codes return @mod_codes if @mod_codes @mod_codes = [] snapshots.each do |s| s.content.each.each do |i| i.mod_codes.each do |mod_code| @mod_codes << {:mod_code => mod_code, :name => i.name} end end end return @mod_codes end |
#write ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/d3_mpq/mod_code_analyzer.rb', line 11 def write # puts attributes s = ["ModCode"] attributes.each do |e| s << "#{e[:mod_code]}#{SEPERATOR}" + e[:names].join(SEPERATOR) end path = File.join("analyze", @output) File.open("#{path}.csv", 'w') { |f| f.write(s.join("\n")) } end |