Class: Okura::CharTypes

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

Instance Method Summary collapse

Constructor Details

#initializeCharTypes

Returns a new instance of CharTypes.



332
333
334
335
336
# File 'lib/okura.rb', line 332

def initialize
  @types={}
  @mapping={}
  @compat_mapping={}
end

Instance Method Details

#default_typeObject



353
354
355
# File 'lib/okura.rb', line 353

def default_type
  named 'DEFAULT'
end

#define_map(charcode, type, compat_types) ⇒ Object



345
346
347
348
349
# File 'lib/okura.rb', line 345

def define_map charcode,type,compat_types
  @mapping[charcode]=type
  type.add charcode
  compat_types.each{|ct|ct.add charcode}
end

#define_type(name, invoke, group, length) ⇒ Object



342
343
344
# File 'lib/okura.rb', line 342

def define_type name,invoke,group,length
  @types[name]=CharType.new(name,invoke,group,length)
end

#named(name) ⇒ Object



350
351
352
# File 'lib/okura.rb', line 350

def named name
  @types[name] || (raise "Undefined char type: #{name}")
end

#type_for(charcode) ⇒ Object



337
338
339
340
341
# File 'lib/okura.rb', line 337

def type_for charcode
  @mapping[charcode]||default_type||
    (raise "Char type for 0x#{charcode.to_s(16)} is not defined,"+
     " and DEFAULT type is not defined too")
end