Module: WahWah

Defined in:
lib/wahwah.rb,
lib/wahwah/tag.rb,
lib/wahwah/errors.rb,
lib/wahwah/helper.rb,
lib/wahwah/id3/v1.rb,
lib/wahwah/id3/v2.rb,
lib/wahwah/asf_tag.rb,
lib/wahwah/mp3_tag.rb,
lib/wahwah/mp4_tag.rb,
lib/wahwah/ogg_tag.rb,
lib/wahwah/version.rb,
lib/wahwah/flac_tag.rb,
lib/wahwah/mp4/atom.rb,
lib/wahwah/ogg/page.rb,
lib/wahwah/riff_tag.rb,
lib/wahwah/id3/frame.rb,
lib/wahwah/lazy_read.rb,
lib/wahwah/ogg/pages.rb,
lib/wahwah/asf/object.rb,
lib/wahwah/flac/block.rb,
lib/wahwah/riff/chunk.rb,
lib/wahwah/ogg/packets.rb,
lib/wahwah/ogg/flac_tag.rb,
lib/wahwah/ogg/opus_tag.rb,
lib/wahwah/tag_delegate.rb,
lib/wahwah/id3/v2_header.rb,
lib/wahwah/id3/frame_body.rb,
lib/wahwah/ogg/vorbis_tag.rb,
lib/wahwah/mp3/vbri_header.rb,
lib/wahwah/mp3/xing_header.rb,
lib/wahwah/ogg/vorbis_comment.rb,
lib/wahwah/id3/text_frame_body.rb,
lib/wahwah/id3/genre_frame_body.rb,
lib/wahwah/id3/image_frame_body.rb,
lib/wahwah/flac/streaminfo_block.rb,
lib/wahwah/mp3/mpeg_frame_header.rb,
lib/wahwah/id3/comment_frame_body.rb

Defined Under Namespace

Modules: Asf, Flac, Helper, ID3, LazyRead, Mp3, Mp4, Ogg, Riff, TagDelegate Classes: AsfTag, FlacTag, Mp3Tag, Mp4Tag, OggTag, RiffTag, Tag, WahWahArgumentError, WahWahNotImplementedError

Constant Summary collapse

FORMATE_MAPPING =
{
  Mp3Tag: ['mp3'],
  OggTag: ['ogg', 'oga', 'opus'],
  RiffTag: ['wav'],
  FlacTag: ['flac'],
  AsfTag: ['wma'],
  Mp4Tag: ['m4a']
}.freeze
VERSION =
'1.1.0'

Class Method Summary collapse

Class Method Details

.open(file_path) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/wahwah.rb', line 62

def self.open(file_path)
  file_path = file_path.to_path if file_path.respond_to? :to_path
  file_path = file_path.to_str

  file_format = Helper.file_format(file_path)

  raise WahWahArgumentError, 'File is not exists' unless File.exist? file_path
  raise WahWahArgumentError, 'File is unreadable' unless File.readable? file_path
  raise WahWahArgumentError, 'File is empty' unless File.size(file_path) > 0
  raise WahWahArgumentError, 'No supported format found' unless support_formats.include? file_format

  FORMATE_MAPPING.each do |tag, formats|
    break const_get(tag).new(file_path) if formats.include?(file_format)
  end
end

.support_formatsObject



78
79
80
# File 'lib/wahwah.rb', line 78

def self.support_formats
  FORMATE_MAPPING.values.flatten
end