Class: SequencescapeExcel::ConditionalFormatting
- Inherits:
-
Object
- Object
- SequencescapeExcel::ConditionalFormatting
- Includes:
- Helpers::Attributes
- Defined in:
- app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb
Overview
A single conditional formatting rule. This will consist of: - options: which relate to Excel options e.g. type: :cellIs - style: The style which will be added when conditional formatting applies. - formula: See Formula class.
Instance Method Summary collapse
-
#formula=(options) ⇒ Object
Create a new Formula object.
-
#initialize(attributes = {}) ⇒ ConditionalFormatting
constructor
A new instance of ConditionalFormatting.
- #initialize_dup(source) ⇒ Object
- #inspect ⇒ Object
-
#styled? ⇒ Boolean
A conditional formatting is styled if the dxfId is present.
-
#to_h ⇒ Object
Return the options as a hash.
-
#update(attributes = {}) ⇒ Object
If a worksheet attribute is present then add the conditional formatting style to the workbook.
Methods included from Helpers::Attributes
Constructor Details
#initialize(attributes = {}) ⇒ ConditionalFormatting
Returns a new instance of ConditionalFormatting.
17 18 19 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 17 def initialize(attributes = {}) super end |
Instance Method Details
#formula=(options) ⇒ Object
Create a new Formula object.
34 35 36 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 34 def formula=() @formula = Formula.new() end |
#initialize_dup(source) ⇒ Object
56 57 58 59 60 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 56 def initialize_dup(source) self. = source..dup self.formula = source.formula.to_h if source.formula.present? super end |
#inspect ⇒ Object
62 63 64 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 62 def inspect "<#{self.class}: @name=#{name}, @options=#{}, @style=#{style}, @formula=#{formula}>" end |
#styled? ⇒ Boolean
A conditional formatting is styled if the dxfId is present.
40 41 42 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 40 def styled? ['dxfId'].present? end |
#to_h ⇒ Object
Return the options as a hash
52 53 54 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 52 def to_h .to_hash end |
#update(attributes = {}) ⇒ Object
If a worksheet attribute is present then add the conditional formatting style to the workbook. If conditional formatting has a formula then update the formula option with the passed attributes.
26 27 28 29 30 |
# File 'app/sequencescape_excel/sequencescape_excel/conditional_formatting.rb', line 26 def update(attributes = {}) ['dxfId'] = attributes[:worksheet].workbook.styles.add_style(style) if attributes[:worksheet].present? ['formula'] = formula.update(attributes).to_s if formula.present? self end |