Class: Applyrics::StringsFile

Inherits:
Object
  • Object
show all
Defined in:
lib/applyrics/stringsfile.rb

Defined Under Namespace

Classes: Parser

Instance Method Summary collapse

Constructor Details

#initialize(filename, data = nil) ⇒ StringsFile

Returns a new instance of StringsFile.



5
6
7
8
9
10
11
# File 'lib/applyrics/stringsfile.rb', line 5

def initialize(filename, data=nil)
  @filename = filename
  @hash = data.nil? ? {} : data
  if data.nil?
    read
  end
end

Instance Method Details

#hashObject



32
33
34
# File 'lib/applyrics/stringsfile.rb', line 32

def hash
  @hash
end

#have_key?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/applyrics/stringsfile.rb', line 24

def have_key?
  # Not implemented...
end

#keysObject



20
21
22
# File 'lib/applyrics/stringsfile.rb', line 20

def keys
  # Not implemented...
end

#readObject



13
14
15
16
17
18
# File 'lib/applyrics/stringsfile.rb', line 13

def read
  @hash = {}
  parser = Parser.new(@hash)
  File.open(@filename, 'rb:utf-16LE:utf-8') { |fd| parser.parse fd }
  self
end

#string_for_key(key) ⇒ Object



28
29
30
# File 'lib/applyrics/stringsfile.rb', line 28

def string_for_key(key)
  # Not implemented...
end