Class: Rubiks::CalculatedMeasure

Inherits:
NamedObject show all
Defined in:
lib/rubiks/calculated_measure.rb

Instance Method Summary collapse

Methods inherited from NamedObject

[], #caption, clear!, #column, default, #default_json_attributes, #default_xml_attributes, define, #description, find_or_create, #hidden, #icon_type, #initialize, instances, #name, #table, #to_json

Constructor Details

This class inherits a constructor from Rubiks::NamedObject

Instance Method Details

#format_string(new_value = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/rubiks/calculated_measure.rb', line 9

def format_string(new_value=nil, options={})
  @format_string = new_value.to_s if new_value.present?
  @format_string ||= @options[:format_string]
end

#formula(new_value = nil, options = {}) ⇒ Object



4
5
6
7
# File 'lib/rubiks/calculated_measure.rb', line 4

def formula(new_value=nil, options={})
  @formula = new_value.to_s if new_value.present?
  @formula ||= @options[:formula]
end

#to_xml(builder = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/rubiks/calculated_measure.rb', line 14

def to_xml(builder = nil)
  builder = builder || new_builder

  xml_attrs = default_xml_attributes
  xml_attrs[:dimension] = 'Measures'
  xml_attrs[:formula] = formula if formula.present?
  xml_attrs[:formatString] = format_string if format_string.present?

  builder.calculatedMember(xml_attrs)
end