Class: FFProbe::Entity

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

Direct Known Subclasses

FileInfo, FrameInfo, PacketInfo, StreamInfo, TagsInfo

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#unitsObject

Returns the value of attribute units.



11
12
13
# File 'lib/ffprobe/entity.rb', line 11

def units
  @units
end

Class Method Details

.from_hash(hash, units = false) ⇒ Object



4
5
6
7
8
9
# File 'lib/ffprobe/entity.rb', line 4

def self.from_hash(hash,units=false)
  target = new
  target.units = units
  hash.each {|k,v| target.__send__("#{k}=", v) }
  target
end

.units(mapping) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ffprobe/entity.rb', line 14

def self.units(mapping)
  mapping.each do |property,unit|
    self.class_eval <<-EOF
      def #{property}=(val)
        if units?
          if val.nil?
            @#{property} = nil
          else
            @#{property} = Unit.new("\#{val} #{unit}")
          end
        else
          @#{property} = val
        end
      end
    EOF
  end
end

Instance Method Details

#units?Object

Returns the value of attribute units.



12
13
14
# File 'lib/ffprobe/entity.rb', line 12

def units
  @units
end