Class: GOVUKDesignSystemFormBuilder::Containers::CharacterCount

Inherits:
Base
  • Object
show all
Defined in:
lib/govuk_design_system_formbuilder/containers/character_count.rb

Instance Method Summary collapse

Methods inherited from Base

#field_id, #to_s

Constructor Details

#initialize(builder, max_words:, max_chars:, threshold:) ⇒ CharacterCount

Returns a new instance of CharacterCount.



4
5
6
7
8
9
10
11
12
# File 'lib/govuk_design_system_formbuilder/containers/character_count.rb', line 4

def initialize(builder, max_words:, max_chars:, threshold:)
  super(builder, nil, nil)

  fail ArgumentError, 'limit can be words or chars' if max_words && max_chars

  @max_words = max_words
  @max_chars = max_chars
  @threshold = threshold
end

Instance Method Details

#html(&block) ⇒ Object



14
15
16
17
18
# File 'lib/govuk_design_system_formbuilder/containers/character_count.rb', line 14

def html(&block)
  return yield unless limit?

  tag.div(**options, &block)
end