Class: Column
- Inherits:
-
Object
- Object
- Column
- Defined in:
- lib/surpass/column.rb
Instance Attribute Summary collapse
-
#collapse ⇒ Object
Returns the value of attribute collapse.
-
#hidden ⇒ Object
Returns the value of attribute hidden.
-
#index ⇒ Object
Returns the value of attribute index.
-
#level ⇒ Object
Returns the value of attribute level.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(index, parent) ⇒ Column
constructor
A new instance of Column.
- #set_style(style) ⇒ Object
- #to_biff ⇒ Object
- #width_in_pixels ⇒ Object
Constructor Details
#initialize(index, parent) ⇒ Column
Returns a new instance of Column.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/surpass/column.rb', line 8 def initialize(index, parent) is_int = index.is_a?(Integer) in_range = (index >= 0) && (index <= 255) raise "column index #{index} is not valid" unless is_int && in_range @index = index @parent = parent @parent_wb = parent.parent @xf_index = 0x0F @width = 0x0B92 @hidden = 0 @level = 0 @collapse = 0 end |
Instance Attribute Details
#collapse ⇒ Object
Returns the value of attribute collapse.
6 7 8 |
# File 'lib/surpass/column.rb', line 6 def collapse @collapse end |
#hidden ⇒ Object
Returns the value of attribute hidden.
4 5 6 |
# File 'lib/surpass/column.rb', line 4 def hidden @hidden end |
#index ⇒ Object
Returns the value of attribute index.
2 3 4 |
# File 'lib/surpass/column.rb', line 2 def index @index end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/surpass/column.rb', line 5 def level @level end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/surpass/column.rb', line 3 def width @width end |
Instance Method Details
#set_style(style) ⇒ Object
32 33 34 |
# File 'lib/surpass/column.rb', line 32 def set_style(style) @xf_index = @parent_wb.add_style(style) end |
#to_biff ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/surpass/column.rb', line 24 def to_biff = (as_numeric(@hidden) & 0x01) << 0 |= (@level & 0x07) << 8 |= (as_numeric(@collapse) & 0x01) << 12 ColInfoRecord.new(@index, @index, @width, @xf_index, ).to_biff end |
#width_in_pixels ⇒ Object
36 37 38 39 |
# File 'lib/surpass/column.rb', line 36 def width_in_pixels # *** Approximation **** (self.width * 0.0272 + 0.446).round end |