Class: CSVPlusPlus::Modifier
- Inherits:
-
Object
- Object
- CSVPlusPlus::Modifier
- Defined in:
- lib/csv_plus_plus/modifier.rb
Overview
A container representing the operations that can be applied to a cell or row
Instance Attribute Summary collapse
-
#bordercolor ⇒ Object
Returns the value of attribute bordercolor.
-
#borders ⇒ Object
readonly
Returns the value of attribute borders.
-
#borderstyle ⇒ Object
Style of border.
-
#color ⇒ Object
Returns the value of attribute color.
-
#expand ⇒ Object
Returns the value of attribute expand.
-
#fontcolor ⇒ Object
Returns the value of attribute fontcolor.
-
#fontfamily ⇒ Object
Returns the value of attribute fontfamily.
-
#fontsize ⇒ Object
Returns the value of attribute fontsize.
-
#formats ⇒ Object
readonly
Returns the value of attribute formats.
-
#note ⇒ Object
Returns the value of attribute note.
-
#numberformat ⇒ Object
Returns the value of attribute numberformat.
-
#row_level ⇒ Object
Returns the value of attribute row_level.
-
#validation ⇒ Object
Returns the value of attribute validation.
Instance Method Summary collapse
-
#align=(direction) ⇒ Object
Set an align format.
-
#aligned?(direction) ⇒ Boolean
Is it aligned to a given direction?.
-
#any_border? ⇒ Boolean
Are there any borders set?.
-
#border=(side) ⇒ Object
Assign a border.
-
#border_all? ⇒ Boolean
Does this have a border along all sides?.
-
#border_along?(side) ⇒ Boolean
Does this have a border along
side
?. -
#cell_level? ⇒ Boolean
Is this a cell-level modifier?.
-
#format=(value) ⇒ Object
Set a format.
-
#formatted?(type) ⇒ Boolean
Is the given format set?.
-
#freeze! ⇒ Object
Freeze the row from edits.
-
#frozen? ⇒ Boolean
Is the row forzen?.
-
#initialize(row_level: false) ⇒ Modifier
constructor
initialize.
-
#row_level! ⇒ Object
Mark this modifer as row-level.
-
#row_level? ⇒ Boolean
Is this a row-level modifier?.
-
#take_defaults_from!(other) ⇒ Object
Create a new modifier instance, with all values defaulted from
other
. -
#to_s ⇒ Object
to_s.
Constructor Details
#initialize(row_level: false) ⇒ Modifier
initialize
17 18 19 20 21 22 23 |
# File 'lib/csv_plus_plus/modifier.rb', line 17 def initialize(row_level: false) @row_level = row_level @freeze = false @align = ::Set.new @borders = ::Set.new @formats = ::Set.new end |
Instance Attribute Details
#bordercolor ⇒ Object
Returns the value of attribute bordercolor.
12 13 14 |
# File 'lib/csv_plus_plus/modifier.rb', line 12 def bordercolor @bordercolor end |
#borders ⇒ Object (readonly)
Returns the value of attribute borders.
12 13 14 |
# File 'lib/csv_plus_plus/modifier.rb', line 12 def borders @borders end |
#borderstyle ⇒ Object
Style of border
106 107 108 |
# File 'lib/csv_plus_plus/modifier.rb', line 106 def borderstyle @borderstyle || 'solid' end |
#color ⇒ Object
Returns the value of attribute color.
12 13 14 |
# File 'lib/csv_plus_plus/modifier.rb', line 12 def color @color end |
#expand ⇒ Object
Returns the value of attribute expand.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def @expand end |
#fontcolor ⇒ Object
Returns the value of attribute fontcolor.
12 13 14 |
# File 'lib/csv_plus_plus/modifier.rb', line 12 def fontcolor @fontcolor end |
#fontfamily ⇒ Object
Returns the value of attribute fontfamily.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def fontfamily @fontfamily end |
#fontsize ⇒ Object
Returns the value of attribute fontsize.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def fontsize @fontsize end |
#formats ⇒ Object (readonly)
Returns the value of attribute formats.
12 13 14 |
# File 'lib/csv_plus_plus/modifier.rb', line 12 def formats @formats end |
#note ⇒ Object
Returns the value of attribute note.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def note @note end |
#numberformat ⇒ Object
Returns the value of attribute numberformat.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def numberformat @numberformat end |
#row_level ⇒ Object
Returns the value of attribute row_level.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def row_level @row_level end |
#validation ⇒ Object
Returns the value of attribute validation.
14 15 16 |
# File 'lib/csv_plus_plus/modifier.rb', line 14 def validation @validation end |
Instance Method Details
#align=(direction) ⇒ Object
Set an align format. direction
must be ‘center’, ‘left’, ‘right’, ‘bottom’
26 27 28 |
# File 'lib/csv_plus_plus/modifier.rb', line 26 def align=(direction) @align << direction end |
#aligned?(direction) ⇒ Boolean
Is it aligned to a given direction?
31 32 33 |
# File 'lib/csv_plus_plus/modifier.rb', line 31 def aligned?(direction) @align.include?(direction) end |
#any_border? ⇒ Boolean
Are there any borders set?
61 62 63 |
# File 'lib/csv_plus_plus/modifier.rb', line 61 def any_border? !@borders.empty? end |
#border=(side) ⇒ Object
Assign a border. side
must be ‘top’, ‘left’, ‘bottom’, ‘right’ or ‘all’
41 42 43 |
# File 'lib/csv_plus_plus/modifier.rb', line 41 def border=(side) @borders << side end |
#border_all? ⇒ Boolean
Does this have a border along all sides?
51 52 53 |
# File 'lib/csv_plus_plus/modifier.rb', line 51 def border_all? @borders.include?('all') end |
#border_along?(side) ⇒ Boolean
Does this have a border along side
?
46 47 48 |
# File 'lib/csv_plus_plus/modifier.rb', line 46 def border_along?(side) border_all? || @borders.include?(side) end |
#cell_level? ⇒ Boolean
Is this a cell-level modifier?
101 102 103 |
# File 'lib/csv_plus_plus/modifier.rb', line 101 def cell_level? !@row_level end |
#format=(value) ⇒ Object
Set a format. type
must be ‘bold’, ‘italic’, ‘underline’ or ‘strikethrough’
71 72 73 |
# File 'lib/csv_plus_plus/modifier.rb', line 71 def format=(value) @formats << value end |
#formatted?(type) ⇒ Boolean
Is the given format set?
76 77 78 |
# File 'lib/csv_plus_plus/modifier.rb', line 76 def formatted?(type) @formats.include?(type) end |
#freeze! ⇒ Object
Freeze the row from edits
81 82 83 |
# File 'lib/csv_plus_plus/modifier.rb', line 81 def freeze! @frozen = true end |
#frozen? ⇒ Boolean
Is the row forzen?
86 87 88 |
# File 'lib/csv_plus_plus/modifier.rb', line 86 def frozen? @frozen end |
#row_level! ⇒ Object
Mark this modifer as row-level
91 92 93 |
# File 'lib/csv_plus_plus/modifier.rb', line 91 def row_level! @row_level = true end |
#row_level? ⇒ Boolean
Is this a row-level modifier?
96 97 98 |
# File 'lib/csv_plus_plus/modifier.rb', line 96 def row_level? @row_level end |
#take_defaults_from!(other) ⇒ Object
Create a new modifier instance, with all values defaulted from other
117 118 119 120 121 122 |
# File 'lib/csv_plus_plus/modifier.rb', line 117 def take_defaults_from!(other) instance_variables.each do |property| value = other.instance_variable_get(property) instance_variable_set(property, value.clone) end end |
#to_s ⇒ Object
to_s
111 112 113 114 |
# File 'lib/csv_plus_plus/modifier.rb', line 111 def to_s # TODO... I dunno, not sure how to manage this "Modifier(row_level: #{@row_level} align: #{@align} format: #{@formats} font_size: #{@font_size})" end |