Class: Etree::InfoFile

Inherits:
Object
  • Object
show all
Defined in:
lib/etree/info_file.rb

Overview

This will parse the info file that comes with a show Typical usage might look like:

info_file = Etree::InfoFile.new :directory => "ph1999-12-31.flacf"
info_file.parse
info_file.band # => "Phish"
info_file.date # => "1999-12-31"
info_file.venue # => "Big Cypress Seminole Indian Reservation, Big Cypress, FL"
info_file.discs.first # => ["Runaway Jim", "Funky Bitch", ...]

Constant Summary collapse

REGEXPS =
{
  :spots      => %r{fob|dfc|btp|d?aud|d?sbd|soundboard|on(\s*|-)stage|matrix|mix|balcony|rail|stand}ix,
  :mics       => %r{caps|omni|cardioid|sc?ho?ep[sz]|neumann|mbho|akg|b&k|dpa|audio.technica}ix,
  :configs    => %r{\b(?:ortf|x[-\/]?y|degrees|blumlein|binaural|nos|din)\b}ix,
  :cables     => %r{kc5|actives?|patch(?:ed)?|coax|optical}ix,
  :pres       => %r{lunatec|apogee|ad1000|ad2k\+?|oade|sonosax|sbm-?1|usb-pre|mini[\s-]?me}ix,
  :dats       => %r{dat|pcm|d[378]|da20|d10|m1|sv-25[05]|da-?p1|tascam|sony|teac|aiwa|panasonic|hhb|portadat|44\.1(?:k(?:hz))|mini-?disc|fostex}ix,
  :laptops    => %r{laptop|dell|ibm|apple|toshiba|(power|i)-?book}ix,
  :digicards  => %r{ieee1394|s.?pdif|zefiro|za-?2|rme|digiface|sb-?live|fiji|turtle\sbeach|delta\sdio|event\sgina|montego|zoltrix|prodif}ix,
  :software   => %r{cd-?wave?|mkwact|shn(?:v3)?|shorten|samplitude|cool[-\s]?edit|sound.?forge|wavelab}ix,
  :venues     => %r{(?:arts cent|theat)(?:er|re)|playhouse|arena|club|university|festival|lounge|room|cafe|field|house|airport|ballroom|college|hall|auditorium|village|temple}ix,
  :states     => %r{A[BLKZR]|BC|CA|CO|CT|DE|FL|GA|HI|I[DLNA]|KS|KY|LA|M[ABEDINSOT]|N[BCDEFVHJMSY]|O[HKNR]|P[AQ]|PEI|QC|RI|S[CDK]|TN|TX|UT|VT|VA|W[AVIY]|DC}x,
  :countries  => %r{Japan|England|Ireland|Brazil|Jamaica|United\s+Kingdom|Italy|South\s+Africa|Sweden|Portugal|Israel|Egypt|Norway|France|India|Finland|United\s+States|China|Mexico|Costa\s+Rica|Ecuador|New\s+Zealand|Puerto\s+Rico|Djibouti}i
}
TRACK_REGEXP =
%r{^(?:d\d+)?t?(\d+)  # sometimes you see d<n>t<m>
\s* (?:[[:punct:]]+)?     # whitespace, some punctuation
\s* (.*)}mix

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ InfoFile

Returns a new instance of InfoFile.



36
37
38
39
40
# File 'lib/etree/info_file.rb', line 36

def initialize(attrs={})
  attrs.each do |k,v|
    send("#{k}=", v)
  end
end

Instance Attribute Details

#bandObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def band
  @band
end

#commentsObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def comments
  @comments
end

#dateObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def date
  @date
end

#directoryObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def directory
  @directory
end

#discsObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def discs
  @discs
end

#info_fileObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def info_file
  @info_file
end

#sourceObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def source
  @source
end

#venueObject

whitespace, the track title



34
35
36
# File 'lib/etree/info_file.rb', line 34

def venue
  @venue
end

Instance Method Details

#parse(info_file = nil) ⇒ Object



42
43
44
45
# File 'lib/etree/info_file.rb', line 42

def parse(info_file=nil)
  self.info_file = info_file if info_file
  parse_info
end

#songs_countObject



58
59
60
# File 'lib/etree/info_file.rb', line 58

def songs_count
  Dir["#{directory}/*.flac"].size
end

#tracksObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/etree/info_file.rb', line 62

def tracks
  @tracks ||= begin
    tracks = []
    discs.each_with_index do |d, dn|
      d.each_with_index do |t, tn|
        tracks << Track.new(:name => t, :number => tn + 1, :disc => dn + 1)
      end
    end
    tracks
  end
end