class ContactCongressParser::Field
Attributes
field_options[R]
name[R]
options[R]
required[R]
Public Class Methods
new(name, options={})
click to toggle source
# File lib/contact_congress_parser/field.rb, line 5 def initialize(name, options={}) @name = normalize_field_name(name) @options = options end
Public Instance Methods
normalize_field_name(name)
click to toggle source
# File lib/contact_congress_parser/field.rb, line 23 def normalize_field_name(name) if name[0] == '$' case name when '$ADDRESS_CITY' then 'City' when '$ADDRESS_COUNTY' then 'County' when '$ADDRESS_STATE_FULL' then 'State' when '$ADDRESS_STATE_POSTAL_ABBREV' then 'State' when '$ADDRESS_STREET' then 'Address' when '$ADDRESS_STREET_2' then 'Address Cont.' when '$ADDRESS_ZIP4' then 'ZIP 4' when '$ADDRESS_ZIP5' then 'ZIP' when '$ADDRESS_ZIP_PLUS_4' then 'ZIP+4' when '$CAMPAIGN_UUID' then 'UUID' when '$CAPTCHA_SOLUTION' then 'captcha' when '$EMAIL' then 'Email Address' when '$MESSAGE' then 'Message' when '$NAME_FIRST' then 'First Name' when '$NAME_FULL' then 'Name' when '$NAME_LAST' then 'Last Name' when '$NAME_PREFIX' then 'Title' when '$NAME_SUFFIX' then 'Suffix' when '$ORG_NAME' then 'Organization' when '$ORG_URL' then 'Organization URL' when '$PHONE' then 'Phone' when '$PHONE_PARENTHESES' then 'Phone Parens' when '$PHONE_WORK' then 'Work Phone' when '$SUBJECT' then 'Subject' when '$TOPIC' then 'Topic' else raise "#{name} not recognized" end else name end end
options_required_str()
click to toggle source
# File lib/contact_congress_parser/field.rb, line 63 def options_required_str required.nil? ? "" : ", required: #{required}" end
options_str()
click to toggle source
# File lib/contact_congress_parser/field.rb, line 59 def options_str Options.new(options[:options]).to_s + options_required_str end
to_s()
click to toggle source
# File lib/contact_congress_parser/field.rb, line 10 def to_s "field(\"#{name}\"#{options_str})" end