Class: SwfRuby::Swf::Rectangle

Inherits:
Object
  • Object
show all
Defined in:
lib/swf_ruby/swf/rectangle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytearray) ⇒ Rectangle

Returns a new instance of Rectangle.



13
14
15
16
17
18
19
20
21
# File 'lib/swf_ruby/swf/rectangle.rb', line 13

def initialize(bytearray)
  @bits = bytearray[0].chr.unpack("B5").first.to_i(2)
  rect_bitstr = bytearray[0..((self.bits/2)+1)].unpack("B*").first
  @xmin = rect_bitstr[5, self.bits].to_i(2)
  @xmax = rect_bitstr[5+self.bits, self.bits].to_i(2)
  @ymin = rect_bitstr[5+2*self.bits, self.bits].to_i(2)
  @ymax = rect_bitstr[5+3*self.bits, self.bits].to_i(2)
  @length = (5+self.bits*4)/8+1 # including padded byte
end

Instance Attribute Details

#bitsObject

Returns the value of attribute bits.



6
7
8
# File 'lib/swf_ruby/swf/rectangle.rb', line 6

def bits
  @bits
end

#lengthObject (readonly)

Returns the value of attribute length.



11
12
13
# File 'lib/swf_ruby/swf/rectangle.rb', line 11

def length
  @length
end

#xmaxObject

Returns the value of attribute xmax.



8
9
10
# File 'lib/swf_ruby/swf/rectangle.rb', line 8

def xmax
  @xmax
end

#xminObject

Returns the value of attribute xmin.



7
8
9
# File 'lib/swf_ruby/swf/rectangle.rb', line 7

def xmin
  @xmin
end

#ymaxObject

Returns the value of attribute ymax.



10
11
12
# File 'lib/swf_ruby/swf/rectangle.rb', line 10

def ymax
  @ymax
end

#yminObject

Returns the value of attribute ymin.



9
10
11
# File 'lib/swf_ruby/swf/rectangle.rb', line 9

def ymin
  @ymin
end