Class: BugReportsClient::FormSchema::Field

Inherits:
Struct
  • Object
show all
Defined in:
lib/bug_reports_client/form_schema.rb

Overview

A single form field parsed from the YAML definition.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#helpObject

Returns the value of attribute help

Returns:

  • (Object)

    the current value of help



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def help
  @help
end

#keyObject

Returns the value of attribute key

Returns:

  • (Object)

    the current value of key



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def key
  @key
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def label
  @label
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def options
  @options
end

#placeholderObject

Returns the value of attribute placeholder

Returns:

  • (Object)

    the current value of placeholder



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def placeholder
  @placeholder
end

#requiredObject

Returns the value of attribute required

Returns:

  • (Object)

    the current value of required



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def required
  @required
end

#rowsObject

Returns the value of attribute rows

Returns:

  • (Object)

    the current value of rows



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def rows
  @rows
end

#sectionObject

Returns the value of attribute section

Returns:

  • (Object)

    the current value of section



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def section
  @section
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



33
34
35
# File 'lib/bug_reports_client/form_schema.rb', line 33

def type
  @type
end

Instance Method Details

#checkbox?Boolean

Returns:

  • (Boolean)


36
# File 'lib/bug_reports_client/form_schema.rb', line 36

def checkbox? = type == "checkbox"

#help_textObject



48
49
50
# File 'lib/bug_reports_client/form_schema.rb', line 48

def help_text
  help || I18n.t("bug_reports_client.fields.#{key}.help", default: nil)
end

#label_textObject

Wording resolution: inline schema values win, then i18n under bug_reports_client.fields..*, then a humanised fallback.



40
41
42
# File 'lib/bug_reports_client/form_schema.rb', line 40

def label_text
  label || I18n.t("bug_reports_client.fields.#{key}.label", default: key.humanize)
end

#placeholder_textObject



44
45
46
# File 'lib/bug_reports_client/form_schema.rb', line 44

def placeholder_text
  placeholder || I18n.t("bug_reports_client.fields.#{key}.placeholder", default: nil)
end

#prompt_textObject



52
53
54
55
# File 'lib/bug_reports_client/form_schema.rb', line 52

def prompt_text
  I18n.t("bug_reports_client.fields.#{key}.prompt",
         default: I18n.t("bug_reports_client.form.select_prompt"))
end

#required?Boolean

Returns:

  • (Boolean)


34
# File 'lib/bug_reports_client/form_schema.rb', line 34

def required? = !!required

#select?Boolean

Returns:

  • (Boolean)


35
# File 'lib/bug_reports_client/form_schema.rb', line 35

def select? = type == "select"