class ContactCongressParser::Field::Options

Note this is a class for options not the entire set of options that include options, etc.

Public Class Methods

new(options) click to toggle source
# File lib/contact_congress_parser/field.rb, line 70
def initialize(options)
  @options = options
  if @options
    to_array
    strip
    escape_quotes
    hashify
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/contact_congress_parser/field.rb, line 80
def to_s
  @options || ''
end

Private Instance Methods

escape_quotes() click to toggle source
# File lib/contact_congress_parser/field.rb, line 97
def escape_quotes
  @options.map! { |option| option.gsub('"', '\"') }
end
hashify() click to toggle source
# File lib/contact_congress_parser/field.rb, line 101
def hashify
  @options = ", options: [\"" + @options.join("\", \"") + "\"]"
end
strip() click to toggle source
# File lib/contact_congress_parser/field.rb, line 93
def strip
  @options.map! { |option| option.strip }
end
to_array() click to toggle source
# File lib/contact_congress_parser/field.rb, line 85
def to_array
  @options = case @options
    when Array then @options
    when Hash then @options.keys
    when String then [@options]
  end
end