Class: Primer::TimeAgoComponent
- Defined in:
- app/components/primer/time_ago_component.rb
Overview
Use ‘TimeAgo` to display a time relative to how long ago it was. This component requires JavaScript.
Constant Summary
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
Primer::TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(time:, micro: false, **system_arguments) ⇒ TimeAgoComponent
constructor
A new instance of TimeAgoComponent.
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(time:, micro: false, **system_arguments) ⇒ TimeAgoComponent
Returns a new instance of TimeAgoComponent.
14 15 16 17 18 19 20 21 22 |
# File 'app/components/primer/time_ago_component.rb', line 14 def initialize(time:, micro: false, **system_arguments) @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:datetime] = time.utc.iso8601 @system_arguments[:classes] = class_names("no-wrap", @system_arguments[:classes]) @system_arguments[:tag] = "time-ago" @system_arguments[:format] = "micro" if micro @time = time @micro = micro end |
Instance Method Details
#call ⇒ Object
24 25 26 |
# File 'app/components/primer/time_ago_component.rb', line 24 def call render(Primer::BaseComponent.new(**@system_arguments)) { time_in_words } end |