Sha256: 1d451003d7eeffcc2f0c729cdfd97cbcfaeaf9806fafe8c5961e77ada941ba51
Contents?: true
Size: 966 Bytes
Versions: 4
Compression:
Stored size: 966 Bytes
Contents
module FLV # Common fonctionality to both FLV::Header, FLV::Tag & FLV::Body module Base def self.included(base) base.class_eval do include Packable end end # returns the instance methods # that are proper (i.e. not redefinitions) # and that don't require any argument. def getters(of=self) of.class.ancestors. map{|k| k.instance_methods(false)}. inject{|proper, methods| proper -= methods}. # tricky: first ancestor is of.class, so that's what we start with select{|m| of.class.instance_method(m).arity.between?(-1,0)} end def to_h(attributes = getters) Hash[attributes.map do |a| a = a.to_s.delete("@").to_sym [a, send(a)] end] end def is?(what) kn = self.class.name.downcase [kn, kn.sub("flv::","")].include?(what.to_s.downcase) end def size StringIO.new.packed.write(self) end end end
Version data entries
4 entries across 4 versions & 2 rubygems
Version | Path |
---|---|
marcandre-flvedit-0.6.1 | lib/flv/base.rb |
marcandre-flvedit-0.6.2 | lib/flv/base.rb |
flvedit-0.6.1 | lib/flv/base.rb |
flvedit-0.6.2 | lib/flv/base.rb |