Sha256: 5be9a7b20923bacdf5ecb4ef63d2d371f52a8405e2badc586d54d3ee5a2e37e7
Contents?: true
Size: 1.78 KB
Versions: 10
Compression:
Stored size: 1.78 KB
Contents
require 'glimmer-dsl-libui' require 'facets' include Glimmer Address = Struct.new(:street, :p_o_box, :city, :state, :zip_code) def form_field(model, attribute) attribute = attribute.to_s entry { |e| label attribute.underscore.split('_').map(&:capitalize).join(' ') text <=> [model, attribute] } end def address_form(address_model) form { form_field(address_model, :street) form_field(address_model, :p_o_box) form_field(address_model, :city) form_field(address_model, :state) form_field(address_model, :zip_code) } end def label_pair(model, attribute, value) horizontal_box { label(attribute.to_s.underscore.split('_').map(&:capitalize).join(' ')) label(value.to_s) { text <= [model, attribute] } } end def address(address_model) vertical_box { address_model.each_pair do |attribute, value| label_pair(address_model, attribute, value) end } end address1 = Address.new('123 Main St', '23923', 'Denver', 'Colorado', '80014') address2 = Address.new('2038 Park Ave', '83272', 'Boston', 'Massachusetts', '02101') window('Method-Based Custom Keyword') { margined true horizontal_box { vertical_box { label('Address 1') { stretchy false } address_form(address1) horizontal_separator { stretchy false } label('Address 1 (Saved)') { stretchy false } address(address1) } vertical_separator { stretchy false } vertical_box { label('Address 2') { stretchy false } address_form(address2) horizontal_separator { stretchy false } label('Address 2 (Saved)') { stretchy false } address(address2) } } }.show
Version data entries
10 entries across 10 versions & 1 rubygems