Class: Rfm::Metadata::FieldControl

Inherits:
Object
  • Object
show all
Defined in:
lib/rfm/metadata/field_control.rb

Overview

The FieldControl object represents a field on a FileMaker layout. You can find out what field style the field uses, and the value list attached to it.

Attributes

  • name is the name of the field

  • style is any one of:

    • :edit_box - a normal editable field

    • :scrollable - an editable field with scroll bar

    • :popup_menu - a pop-up menu

    • :checkbox_set - a set of checkboxes

    • :radio_button_set - a set of radio buttons

    • :popup_list - a pop-up list

    • :calendar - a pop-up calendar

  • value_list_name is the name of the attached value list, if any

  • value_list is an array of strings representing the value list items, or nil if this field has no attached value list

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes, meta) ⇒ FieldControl

Returns a new instance of FieldControl.



28
29
30
31
32
# File 'lib/rfm/metadata/field_control.rb', line 28

def initialize(attributes, meta)
	self.layout_meta = meta
	_attach_as_instance_variables attributes
	self
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/rfm/metadata/field_control.rb', line 25

def name
  @name
end

#styleObject (readonly)

Returns the value of attribute style.



25
26
27
# File 'lib/rfm/metadata/field_control.rb', line 25

def style
  @style
end

#value_list_nameObject (readonly)

Returns the value of attribute value_list_name.



25
26
27
# File 'lib/rfm/metadata/field_control.rb', line 25

def value_list_name
  @value_list_name
end

Instance Method Details

#handle_style_element(attributes) ⇒ Object

Handle manual attachment of STYLE element.



35
36
37
# File 'lib/rfm/metadata/field_control.rb', line 35

def handle_style_element(attributes)
	_attach_as_instance_variables attributes, :key_translator=>method(:translate_value_list_key), :value_translator=>method(:translate_style_value)
end

#translate_style_value(raw) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rfm/metadata/field_control.rb', line 39

def translate_style_value(raw)
	#puts ["TRANSLATE_STYLE", raw].join(', ')
	{
		'EDITTEXT'	=>	:edit_box,
	'POPUPMENU'	=>	:popup_menu,
	'CHECKBOX'	=>	:checkbox_set,
	'RADIOBUTTONS'	=>	:radio_button_set,
	'POPUPLIST'	=>	:popup_list,
	'CALENDAR'	=>	:calendar,
	'SCROLLTEXT'	=>	:scrollable,
	}[raw] || raw
end

#translate_value_list_key(raw) ⇒ Object



52
53
54
# File 'lib/rfm/metadata/field_control.rb', line 52

def translate_value_list_key(raw)
{'valuelist'=>'value_list_name'}[raw] || raw	  	
end

#value_listObject



56
57
58
# File 'lib/rfm/metadata/field_control.rb', line 56

def value_list
	layout_meta.value_lists[value_list_name]
end