Class: GovukComponent::PaginationComponent::Item
- Defined in:
- app/components/govuk_component/pagination_component/item.rb
Instance Attribute Summary collapse
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#visually_hidden_text ⇒ Object
readonly
Returns the value of attribute visually_hidden_text.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(number: nil, href: nil, current: false, ellipsis: false, from_pagy: false, visually_hidden_text: nil, classes: [], html_attributes: {}) ⇒ Item
constructor
A new instance of Item.
Methods inherited from Base
Constructor Details
#initialize(number: nil, href: nil, current: false, ellipsis: false, from_pagy: false, visually_hidden_text: nil, classes: [], html_attributes: {}) ⇒ Item
Returns a new instance of Item.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 4 def initialize(number: nil, href: nil, current: false, ellipsis: false, from_pagy: false, visually_hidden_text: nil, classes: [], html_attributes: {}) @number = number @href = href @visually_hidden_text = visually_hidden_text # We have three modes for rendering links: # # * link (a link to another page) # * current (a link to the current page) # * gap (an ellipsis symbol) # # Pagy sets these by object type: # Integer = link # String = current # :gap = gap # # The original Nunjucks component has two boolean settings instead, # ellipsis and current. When ellipsis is true all other arguments are # ignored @mode = from_pagy ? pagy_mode(number) : manual_mode(ellipsis, current) super(classes:, html_attributes:) end |
Instance Attribute Details
#href ⇒ Object (readonly)
Returns the value of attribute href.
2 3 4 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 2 def href @href end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
2 3 4 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 2 def mode @mode end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
2 3 4 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 2 def number @number end |
#visually_hidden_text ⇒ Object (readonly)
Returns the value of attribute visually_hidden_text.
2 3 4 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 2 def visually_hidden_text @visually_hidden_text end |
Instance Method Details
#call ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/govuk_component/pagination_component/item.rb', line 28 def call case mode when :link link(current: false) when :current link(current: true) when :gap ellipsis_item end end |