Module: FLV::Base
Overview
Common fonctionality to both FLV::Header, FLV::Tag & FLV::Body
Class Method Summary collapse
Instance Method Summary collapse
-
#getters(of = self) ⇒ Object
returns the instance methods that are proper (i.e. not redefinitions) and that don’t require any argument.
- #is?(what) ⇒ Boolean
- #size ⇒ Object
- #to_hash(attributes = getters) ⇒ Object
Class Method Details
.included(base) ⇒ Object
4 5 6 7 8 |
# File 'lib/flvedit/flv/base.rb', line 4 def self.included(base) base.class_eval do include Packable end end |
Instance Method Details
#getters(of = self) ⇒ Object
returns the instance methods that are proper (i.e. not redefinitions) and that don’t require any argument.
13 14 15 16 17 18 |
# File 'lib/flvedit/flv/base.rb', line 13 def getters(of=self) of.class.ancestors. map{|k| k.instance_methods(false)}. inject(:-). # cute and tricky! remember that the first ancestor is of.class itself, so that's what we start with select{|m| of.class.instance_method(m).arity.between?(-1,0)} end |
#is?(what) ⇒ Boolean
29 30 31 32 |
# File 'lib/flvedit/flv/base.rb', line 29 def is?(what) kn = self.class.name.downcase [kn, kn.sub("flv::","")].include?(what.to_s.downcase) end |
#size ⇒ Object
34 35 36 |
# File 'lib/flvedit/flv/base.rb', line 34 def size StringIO.new.packed.write(self) end |
#to_hash(attributes = getters) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/flvedit/flv/base.rb', line 20 def to_hash(attributes = getters) Hash[ attributes.map do |a| a = a.to_s.delete("@").to_sym [a, send(a)] end ] end |