Class: Klear::Choreography

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#archiveObject (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

#fpsObject (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

#gammaObject (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

#geometryObject (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

#locationObject

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

#framecountObject



66
67
68
# File 'lib/klear/choreography.rb', line 66

def framecount
  @frames.count
end

#framesizeObject



62
63
64
# File 'lib/klear/choreography.rb', line 62

def framesize
  @geometry[:columns] * @geometry[:rows]
end

#idObject



58
59
60
# File 'lib/klear/choreography.rb', line 58

def id
  File.basename(self.location, ".kle")
end

#infoObject



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 <<-INFO
Klear file at: #{@location}

Settings:
----------------
fps     : #{@fps}
gamma   : #{@gamma}
geometry: 
  columns: #{@geometry[:columns]}
  rows   : #{@geometry[:rows]}
----------------


Frames:
----------------
framesize : #{framesize}
framecount: #{framecount}
----------------


MANIFEST:
----------------
#{@archive.manifest}
----------------
  INFO
end