Class: Bvh::Exporter
- Inherits:
-
Object
- Object
- Bvh::Exporter
- Defined in:
- lib/bvh/exporter.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #export(bvh) ⇒ Object
-
#initialize(file) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(file) ⇒ Exporter
Returns a new instance of Exporter.
6 7 8 |
# File 'lib/bvh/exporter.rb', line 6 def initialize(file) @filename = file end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/bvh/exporter.rb', line 3 def filename @filename end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
4 5 6 |
# File 'lib/bvh/exporter.rb', line 4 def source @source end |
Instance Method Details
#export(bvh) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bvh/exporter.rb', line 10 def export(bvh) #raise "File exists" if File.exist?(filename) unless bvh.frame_count == 0 raise ArgumentError, "Frame time is 0; this would result in infinite FPS!" if bvh.frame_time == 0 raise ArgumentError, "Frame time is #{bvh.frame_time}! Should be a positive number." if bvh.frame_time < 0 end @bvh = bvh File.open(filename, "w+") do |file| @file = file file.puts "HIERARCHY" bvh.skeletons.each { |skel| export_skeleton(skel) } export_motion(bvh.motion) file.puts # end with a blank line end end |