Class: EhbrsRubyUtils::Vg::Wii::GameFile
- Inherits:
-
Pathname
- Object
- Pathname
- EhbrsRubyUtils::Vg::Wii::GameFile
- Defined in:
- lib/ehbrs_ruby_utils/vg/wii/game_file.rb
Constant Summary collapse
- DISC_NUMBER_PATTERN =
/disc.?(\d)/i.freeze
- FORMAT =
::EacRubyUtils::CustomFormat.new( b: :basename, d: :dirname, D: :disc_number, e: :extname, i: :id6, m: :normalized_disc_name, n: :disc_name, N: :nintendont_basename, s: :sanitized_disc_name, t: :database_title, T: :disc_type )
Instance Method Summary collapse
- #database_title ⇒ Object
- #disc_name ⇒ Object
- #disc_number ⇒ Object
- #disc_type ⇒ Object
- #format(string) ⇒ Object
- #id6 ⇒ Object
- #nintendont_basename ⇒ Object
- #normalized_disc_name ⇒ Object
- #sanitized_disc_name ⇒ Object
- #valid? ⇒ Boolean
- #wit_path ⇒ Object
Instance Method Details
#database_title ⇒ Object
32 33 34 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 32 def database_title properties.fetch('DB title') end |
#disc_name ⇒ Object
36 37 38 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 36 def disc_name properties.fetch('Disc name') end |
#disc_number ⇒ Object
40 41 42 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 40 def disc_number DISC_NUMBER_PATTERN.if_match(basename.to_s, false) { |m| m[1].to_i }.if_present(1) end |
#disc_type ⇒ Object
44 45 46 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 44 def disc_type properties.fetch('File & disc type/type') end |
#format(string) ⇒ Object
48 49 50 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 48 def format(string) FORMAT.format(string).with(self) end |
#id6 ⇒ Object
61 62 63 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 61 def id6 properties.fetch('Disc & part IDs/disc') end |
#nintendont_basename ⇒ Object
56 57 58 59 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 56 def nintendont_basename n = disc_number n == 1 ? 'game' : "disc#{n}" end |
#normalized_disc_name ⇒ Object
52 53 54 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 52 def normalized_disc_name sanitized_disc_name.downcase end |
#sanitized_disc_name ⇒ Object
65 66 67 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 65 def sanitized_disc_name ::ActiveSupport::Inflector.transliterate(disc_name).gsub(/[^0-9a-z ]/i, '') end |
#valid? ⇒ Boolean
69 70 71 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 69 def valid? properties.present? end |
#wit_path ⇒ Object
73 74 75 |
# File 'lib/ehbrs_ruby_utils/vg/wii/game_file.rb', line 73 def wit_path ::EhbrsRubyUtils::Vg::Wii::Wit::Path.new(disc_type, self) end |