class Bytepack::CustomData
Public Class Methods
code_by_struct(struct)
click to toggle source
# File lib/bytepack/custom_data.rb, line 26 def code_by_struct(struct) struct::TYPE_CODE if struct < Struct end
inherited(child)
click to toggle source
# File lib/bytepack/custom_data.rb, line 7 def inherited(child) @subclasses << child end
struct_by_code(code)
click to toggle source
# File lib/bytepack/custom_data.rb, line 30 def struct_by_code(code) subclasses {|child| child::TYPE_CODE == code} end
struct_by_ruby_type(val)
click to toggle source
# File lib/bytepack/custom_data.rb, line 22 def struct_by_ruby_type(val) subclasses {|child| val.is_a?(child::RUBY_TYPE)} end
subclasses() { |child| ... }
click to toggle source
# File lib/bytepack/custom_data.rb, line 11 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