Class: NWN::Tlk::TlkSet
- Inherits:
-
Object
- Object
- NWN::Tlk::TlkSet
- Defined in:
- lib/nwn/tlk.rb
Overview
A TlkSet wraps a set of File objects, each pointing to the respective tlk file, making retrieval easier.
Instance Attribute Summary collapse
-
#cf ⇒ Object
readonly
The custom female Tlk, if specified (cm if no female custom tlk has been specified, nil if none).
-
#cm ⇒ Object
readonly
The custom male Tlk, or nil.
-
#df ⇒ Object
readonly
The default female Tlk, (or the default male).
-
#dm ⇒ Object
readonly
The default male Tlk.
Instance Method Summary collapse
- #[](id, gender = :male) ⇒ Object
-
#initialize(tlk, tlkf = nil, custom = nil, customf = nil) ⇒ TlkSet
constructor
A new instance of TlkSet.
Constructor Details
#initialize(tlk, tlkf = nil, custom = nil, customf = nil) ⇒ TlkSet
Returns a new instance of TlkSet.
154 155 156 157 158 159 |
# File 'lib/nwn/tlk.rb', line 154 def initialize tlk, tlkf = nil, custom = nil, customf = nil @dm = Tlk.new(tlk) @df = tlkf ? Tlk.new(tlkf) : @dm @cm = custom ? Tlk.new(custom) : nil @cf = customf ? Tlk.new(customf) : @cm end |
Instance Attribute Details
#cf ⇒ Object (readonly)
The custom female Tlk, if specified (cm if no female custom tlk has been specified, nil if none).
152 153 154 |
# File 'lib/nwn/tlk.rb', line 152 def cf @cf end |
#cm ⇒ Object (readonly)
The custom male Tlk, or nil.
150 151 152 |
# File 'lib/nwn/tlk.rb', line 150 def cm @cm end |
#df ⇒ Object (readonly)
The default female Tlk, (or the default male).
148 149 150 |
# File 'lib/nwn/tlk.rb', line 148 def df @df end |
#dm ⇒ Object (readonly)
The default male Tlk.
146 147 148 |
# File 'lib/nwn/tlk.rb', line 146 def dm @dm end |
Instance Method Details
#[](id, gender = :male) ⇒ Object
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/nwn/tlk.rb', line 161 def [](id, gender = :male) raise ArgumentError, "Invalid Tlk ID: #{id.inspect}" if id > 0xffffffff (if id < 0x01000000 gender == :female && @df ? @df : @dm else raise ArgumentError, "Wanted a custom ID, but no custom talk table has been specified." unless @cm id -= 0x01000000 gender == :female && @cf ? @cf : @cm end)[id] end |