Class: WolfTrans::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/wolftrans/context.rb

Overview

Represents the context of a translatable string

Direct Known Subclasses

CommonEvent, Database, GameDat, MapEvent

Defined Under Namespace

Classes: CommonEvent, Database, GameDat, MapEvent

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_string(string) ⇒ Object

Parse a string to determine context



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/wolftrans/context.rb', line 9

def self.from_string(string)
  pair = string.split(':', 2)
  if pair.size != 2
    raise "malformed context line"
  end
  type, path = pair
  path = path.split('/')

  case type
  when 'MPS'
    return MapEvent.from_string(path)
  when 'GAMEDAT'
    return GameDat.from_string(path)
  when 'DB'
    return Database.from_string(path)
  when 'COMMONEVENT'
    return CommonEvent.from_string(path)
  end
  raise "unrecognized context type '#{type}'"
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/wolftrans/context.rb', line 4

def eql?(other)
  self.class == other.class
end