Class: Klear::Choreography
- Inherits:
-
Object
- Object
- Klear::Choreography
- Defined in:
- lib/klear/choreography.rb
Overview
Note: Row 0 is the motor setting / this is equivalent to the first value of a blade
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
class Frames < BinData::Record array :numbers, :type => :uint16be, :read_until => :eof end.
-
#fps ⇒ Object
readonly
class Frames < BinData::Record array :numbers, :type => :uint16be, :read_until => :eof end.
-
#gamma ⇒ Object
readonly
class Frames < BinData::Record array :numbers, :type => :uint16be, :read_until => :eof end.
-
#geometry ⇒ Object
readonly
class Frames < BinData::Record array :numbers, :type => :uint16be, :read_until => :eof end.
-
#location ⇒ Object
Returns the value of attribute location.
Class Method Summary collapse
Instance Method Summary collapse
-
#each_frame(&blk) ⇒ Object
block_given?.
- #frame(no) ⇒ Object
- #framecount ⇒ Object
- #framesize ⇒ Object
- #id ⇒ Object
- #info ⇒ Object
-
#initialize(archive) ⇒ Choreography
constructor
A new instance of Choreography.
Constructor Details
#initialize(archive) ⇒ Choreography
Returns a new instance of Choreography.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/klear/choreography.rb', line 19 def initialize archive @archive = archive @location = @archive.path #info = YAML.load(@archive.read("META-INF/kle.yml")) info = @archive.info @geometry = info['geometry'] @fps = info['fps'] || 25 @gamma = info['gamma'] || 1.0 @frames = @archive.frames end |
Instance Attribute Details
#archive ⇒ Object (readonly)
class Frames < BinData::Record
array :numbers, :type => :uint16be, :read_until => :eof
end
11 12 13 |
# File 'lib/klear/choreography.rb', line 11 def archive @archive end |
#fps ⇒ Object (readonly)
class Frames < BinData::Record
array :numbers, :type => :uint16be, :read_until => :eof
end
11 12 13 |
# File 'lib/klear/choreography.rb', line 11 def fps @fps end |
#gamma ⇒ Object (readonly)
class Frames < BinData::Record
array :numbers, :type => :uint16be, :read_until => :eof
end
11 12 13 |
# File 'lib/klear/choreography.rb', line 11 def gamma @gamma end |
#geometry ⇒ Object (readonly)
class Frames < BinData::Record
array :numbers, :type => :uint16be, :read_until => :eof
end
11 12 13 |
# File 'lib/klear/choreography.rb', line 11 def geometry @geometry end |
#location ⇒ Object
Returns the value of attribute location.
12 13 14 |
# File 'lib/klear/choreography.rb', line 12 def location @location end |
Class Method Details
.load(path) ⇒ Object
14 15 16 17 |
# File 'lib/klear/choreography.rb', line 14 def self.load path #choreo = Zip::ZipFile.open(path) { |klear| new klear } self.new(Klear::File.new(path)) end |
Instance Method Details
#each_frame(&blk) ⇒ Object
block_given?
74 75 76 77 78 79 |
# File 'lib/klear/choreography.rb', line 74 def each_frame &blk #block_given? (0...framecount).each do |n| myFrame = frame(n) blk.call(myFrame, n+1) end end |
#frame(no) ⇒ Object
70 71 72 |
# File 'lib/klear/choreography.rb', line 70 def frame no @frames.get(no) end |
#framecount ⇒ Object
66 67 68 |
# File 'lib/klear/choreography.rb', line 66 def framecount @frames.count end |
#framesize ⇒ Object
62 63 64 |
# File 'lib/klear/choreography.rb', line 62 def framesize @geometry[:columns] * @geometry[:rows] end |
#id ⇒ Object
58 59 60 |
# File 'lib/klear/choreography.rb', line 58 def id File.basename(self.location, ".kle") end |
#info ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/klear/choreography.rb', line 30 def info puts "Klear file at: \#{@location}\n\nSettings:\n----------------\nfps : \#{@fps}\ngamma : \#{@gamma}\ngeometry: \n columns: \#{@geometry[:columns]}\n rows : \#{@geometry[:rows]}\n----------------\n\n\nFrames:\n----------------\nframesize : \#{framesize}\nframecount: \#{framecount}\n----------------\n\n\nMANIFEST:\n----------------\n\#{@archive.manifest}\n----------------\n INFO\nend\n" |