Sha256: 99509075b7aac6e39fbe5a472bd61d8b4e530a0de565080e7e7cbdad8bddbdda
Contents?: true
Size: 755 Bytes
Versions: 1
Compression:
Stored size: 755 Bytes
Contents
module Bytepack class CustomData < Struct @subclasses = [] class << self def inherited(child) @subclasses << child end def subclasses(&block) selected = nil @subclasses.each do |child| # .find() is too slow if yield(child) selected = child break end end selected if block_given? end def struct_by_ruby_type(val) subclasses {|child| val.is_a?(child::RUBY_TYPE)} end def code_by_struct(struct) struct::TYPE_CODE if struct < Struct end def struct_by_code(code) subclasses {|child| child::TYPE_CODE == code} end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bytepack-0.0.1 | lib/bytepack/custom_data.rb |